mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2026-04-30 00:00:01 -04:00
#660: Farewell, Lena
This commit is contained in:
+35
-27
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
+6
-2
@@ -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.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
Reference in New Issue
Block a user