mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-02 11:05:29 -04:00
Added reader test case for IFF FORM type PBM.
Minor optimization in reading PBM data. Clean-up.
This commit is contained in:
parent
a99c337348
commit
36a05272a5
@ -141,15 +141,16 @@ public class IFFImageReader extends ImageReaderBase {
|
||||
}
|
||||
|
||||
private void readMeta() throws IOException {
|
||||
if (imageInput.readInt() != IFF.CHUNK_FORM) {
|
||||
throw new IIOException("Unknown file format for IFFImageReader");
|
||||
int chunkType = imageInput.readInt();
|
||||
if (chunkType != IFF.CHUNK_FORM) {
|
||||
throw new IIOException(String.format("Unknown file format for IFFImageReader, expected 'FORM': %s", IFFUtil.toChunkStr(chunkType)));
|
||||
}
|
||||
|
||||
int remaining = imageInput.readInt() - 4; // We'll read 4 more in a sec
|
||||
|
||||
formType = imageInput.readInt();
|
||||
if (formType != IFF.TYPE_ILBM && formType != IFF.TYPE_PBM) {
|
||||
throw new IIOException("Only IFF FORM types ILBM and PBM supported: " + IFFUtil.toChunkStr(formType));
|
||||
throw new IIOException(String.format("Only IFF FORM types 'ILBM' and 'PBM ' supported: %s", IFFUtil.toChunkStr(formType)));
|
||||
}
|
||||
|
||||
//System.out.println("IFF type FORM " + toChunkStr(type));
|
||||
@ -243,7 +244,7 @@ public class IFFImageReader extends ImageReaderBase {
|
||||
CTBLChunk ctbl = new CTBLChunk(length);
|
||||
ctbl.readChunk(imageInput);
|
||||
|
||||
// NOTE: We prefer PHCG to ctbl style palette changes, if both are present
|
||||
// NOTE: We prefer PHCG to CTBL style palette changes, if both are present
|
||||
if (paletteChange == null) {
|
||||
paletteChange = ctbl;
|
||||
}
|
||||
@ -494,17 +495,12 @@ public class IFFImageReader extends ImageReaderBase {
|
||||
else if (isConvertToRGB()) {
|
||||
multiPaletteToRGB(srcY, row, pModel, data, 0);
|
||||
}
|
||||
else if (isSHAM()) {
|
||||
throw new UnsupportedOperationException("SHAM not supported (yet)");
|
||||
}
|
||||
else {
|
||||
raster.setDataElements(0, 0, width, 1, row);
|
||||
}
|
||||
}
|
||||
else if (formType == IFF.TYPE_PBM) {
|
||||
// TODO: Arraycopy might not be necessary, if it's okay with row larger than width
|
||||
System.arraycopy(planeData, 0, row, 0, header.bitplanes * planeWidth);
|
||||
raster.setDataElements(0, 0, width, 1, row);
|
||||
raster.setDataElements(0, 0, width, 1, planeData);
|
||||
}
|
||||
else {
|
||||
throw new AssertionError(String.format("Unsupported FORM type: %s", formType));
|
||||
@ -611,7 +607,6 @@ public class IFFImageReader extends ImageReaderBase {
|
||||
|
||||
for (int srcY = 0; srcY < height; srcY++) {
|
||||
for (int c = 0; c < channels; c++) {
|
||||
|
||||
for (int p = 0; p < planesPerChannel; p++) {
|
||||
readPlaneData(pInput, planeData, p * planeWidth, planeWidth);
|
||||
}
|
||||
|
@ -43,7 +43,6 @@ import java.util.List;
|
||||
* @version $Id: IFFImageReaderTestCase.java,v 1.0 Apr 1, 2008 10:39:17 PM haraldk Exp$
|
||||
*/
|
||||
public class IFFImageReaderTest extends ImageReaderAbstractTestCase<IFFImageReader> {
|
||||
// TODO: Need test for IFF PBM
|
||||
protected List<TestData> getTestData() {
|
||||
return Arrays.asList(
|
||||
// 32 bit - Ok
|
||||
@ -58,6 +57,8 @@ public class IFFImageReaderTest extends ImageReaderAbstractTestCase<IFFImageRead
|
||||
new TestData(getClassLoaderResource("/iff/AmigaAmiga.iff"), new Dimension(200, 150)), // 8 color
|
||||
// HAM6 - Ok
|
||||
new TestData(getClassLoaderResource("/iff/Abyss.iff"), new Dimension(320, 400)),
|
||||
// PBM, indexed - Ok
|
||||
new TestData(getClassLoaderResource("/iff/ASH.PBM"), new Dimension(320, 240)),
|
||||
// 256 color indexed - Ok
|
||||
new TestData(getClassLoaderResource("/iff/IKKEGOD.iff"), new Dimension(640, 256)),
|
||||
// 16 color indexed, multi palette (PCHG) - Ok
|
||||
|
BIN
imageio/imageio-iff/src/test/resources/iff/ASH.PBM
Normal file
BIN
imageio/imageio-iff/src/test/resources/iff/ASH.PBM
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user