#660: Farewell, Lena

This commit is contained in:
Harald Kuhr
2022-02-08 10:16:42 +01:00
parent 92bc9c73f6
commit 499b3ef120
24 changed files with 49 additions and 57 deletions
@@ -70,41 +70,49 @@ final class PNMHeaderParser extends HeaderParser {
List<String> comments = new ArrayList<>();
StringBuilder tokenBuffer = new StringBuilder();
while (width == 0 || height == 0 || maxSample == 0) {
String line = input.readLine();
tokenBuffer.delete(0, tokenBuffer.length());
if (line == null) {
throw new IIOException("Unexpeced end of stream");
}
while (tokenBuffer.length() < 16) {
char read = (char) input.readByte();
int commentStart = line.indexOf('#');
if (commentStart >= 0) {
String comment = line.substring(commentStart + 1).trim();
if (!comment.isEmpty()) {
comments.add(comment);
if (read == '#') {
// Read rest of the line as comment
String comment = input.readLine();
if (!comment.trim().isEmpty()) {
comments.add(comment);
}
break;
}
else if (Character.isWhitespace(read)) {
if (tokenBuffer.length() > 0) {
break;
}
}
else {
tokenBuffer.append(read);
}
line = line.substring(0, commentStart);
}
line = line.trim();
String token = tokenBuffer.toString().trim();
if (!line.isEmpty()) {
if (!token.isEmpty()) {
// We have tokens...
String[] tokens = line.split("\\s");
for (String token : tokens) {
if (width == 0) {
width = Integer.parseInt(token);
}
else if (height == 0) {
height = Integer.parseInt(token);
}
else if (maxSample == 0) {
maxSample = Integer.parseInt(token);
}
else {
throw new IIOException("Unknown PNM token: " + token);
}
if (width == 0) {
width = Integer.parseInt(token);
}
else if (height == 0) {
height = Integer.parseInt(token);
}
else if (maxSample == 0) {
maxSample = Integer.parseInt(token);
}
else {
throw new IIOException("Unknown PNM token: " + token);
}
}
}
@@ -54,7 +54,7 @@ public class PAMImageReaderTest extends ImageReaderAbstractTest<PNMImageReader>
@Override
protected List<TestData> getTestData() {
return Arrays.asList(
new TestData(getClassLoaderResource("/pam/lena.pam"), new Dimension(128, 128)), // P7 RGB
new TestData(getClassLoaderResource("/pam/snail2.pam"), new Dimension(256, 256)), // P7 RGB
new TestData(getClassLoaderResource("/pam/rgba.pam"), new Dimension(4, 2)) // P7 RGB_ALPHA
);
}
@@ -50,10 +50,12 @@ public class PNMImageReaderTest extends ImageReaderAbstractTest<PNMImageReader>
@Override
protected List<TestData> getTestData() {
return Arrays.asList(
new TestData(getClassLoaderResource("/ppm/lena.ppm"), new Dimension(128, 128)), // P6 (PPM RAW)
new TestData(getClassLoaderResource("/ppm/snail2.pnm"), new Dimension(256, 256)), // P6 (PPM RAW)
new TestData(getClassLoaderResource("/ppm/colors.ppm"), new Dimension(3, 2)), // P3 (PPM PLAIN)
new TestData(getClassLoaderResource("/pbm/j.pbm"), new Dimension(6, 10)), // P1 (PBM PLAIN)
new TestData(getClassLoaderResource("/pbm/circle2.pnm"), new Dimension(200, 200)), // P4 (PBM RAW)
new TestData(getClassLoaderResource("/pgm/feep.pgm"), new Dimension(24, 7)), // P2 (PGM PLAIN)
new TestData(getClassLoaderResource("/pgm/rays2.pnm"), new Dimension(200, 200)), // P4 (PGM RAW)
new TestData(getClassLoaderResource("/pgm/feep16.pgm"), new Dimension(24, 7)), // P2 (PGM PLAIN, 16 bits/sample)
new TestData(getClassLoaderResource("/pgm/house.l.pgm"), new Dimension(367, 241)), // P5 (PGM RAW)
new TestData(getClassLoaderResource("/ppm/lighthouse_rgb48.ppm"), new Dimension(768, 512)), // P6 (PPM RAW, 16 bits/sample)
@@ -64,10 +66,12 @@ public class PNMImageReaderTest extends ImageReaderAbstractTest<PNMImageReader>
@Override
protected List<TestData> getTestDataForAffineTransformOpCompatibility() {
return Arrays.asList(
new TestData(getClassLoaderResource("/ppm/lena.ppm"), new Dimension(128, 128)), // P6 (PPM RAW)
new TestData(getClassLoaderResource("/ppm/snail2.pnm"), new Dimension(256, 256)), // P6 (PPM RAW)
new TestData(getClassLoaderResource("/ppm/colors.ppm"), new Dimension(3, 2)), // P3 (PPM PLAIN)
new TestData(getClassLoaderResource("/pbm/j.pbm"), new Dimension(6, 10)), // P1 (PBM PLAIN)
new TestData(getClassLoaderResource("/pbm/circle2.pnm"), new Dimension(200, 200)), // P4 (PBM RAW)
new TestData(getClassLoaderResource("/pgm/feep.pgm"), new Dimension(24, 7)), // P2 (PGM PLAIN)
new TestData(getClassLoaderResource("/pgm/rays2.pnm"), new Dimension(200, 200)), // P4 (PGM RAW)
new TestData(getClassLoaderResource("/pgm/feep16.pgm"), new Dimension(24, 7)), // P2 (PGM PLAIN, 16 bits/sample)
new TestData(getClassLoaderResource("/pgm/house.l.pgm"), new Dimension(367, 241)), // P5 (PGM RAW)
new TestData(getClassLoaderResource("/ppm/lighthouse_rgb48.ppm"), new Dimension(768, 512)) // P6 (PPM RAW, 16 bits/sample)
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long