Fixed reading of gray-scale IFFs.

Added some comments & clean-up.
This commit is contained in:
Harald Kuhr 2009-11-04 16:08:20 +01:00
parent 96a74e0b81
commit 0a71af5405
3 changed files with 17 additions and 5 deletions

View File

@ -42,6 +42,7 @@ import java.io.IOException;
*/ */
class CAMGChunk extends IFFChunk { class CAMGChunk extends IFFChunk {
// HIRES=0x8000, LACE=0x4
// #define CAMG_HAM 0x800 /* hold and modify */ // #define CAMG_HAM 0x800 /* hold and modify */
// #define CAMG_EHB 0x80 /* extra halfbrite */ // #define CAMG_EHB 0x80 /* extra halfbrite */

View File

@ -91,6 +91,16 @@ import java.util.List;
* @see <a href="http://en.wikipedia.org/wiki/ILBM">Wikipedia: IFF ILBM</a> * @see <a href="http://en.wikipedia.org/wiki/ILBM">Wikipedia: IFF ILBM</a>
*/ */
public class IFFImageReader extends ImageReaderBase { public class IFFImageReader extends ImageReaderBase {
// http://home.comcast.net/~erniew/lwsdk/docs/filefmts/ilbm.html
// http://www.fileformat.info/format/iff/spec/7866a9f0e53c42309af667c5da3bd426/view.htm
// - Contains definitions of some "new" chunks, as well as alternative FORM types
// TODO: One other existing deep bit ordering that you may encounter is the 21-bit
// NewTek format.
//
// NewTek deep ILBM bit ordering:
// saved first ------------------------------------------------------> saved last
// R7 G7 B7 R6 G6 B6 R5 G5 B5 R4 G4 B4 R3 G3 B3 R2 G2 B2 R1 G1 B1 R0 G0 B0
private BMHDChunk mHeader; private BMHDChunk mHeader;
private CMAPChunk mColorMap; private CMAPChunk mColorMap;
@ -294,9 +304,8 @@ public class IFFImageReader extends ImageReaderBase {
// 8 bit // 8 bit
// May be HAM8 // May be HAM8
if (!isHAM()) { if (!isHAM()) {
// TODO: This is probably a bug, as mColorMap is null in case of gray.. if (mColorMap != null) {
IndexColorModel cm = mColorMap.getIndexColorModel(); IndexColorModel cm = mColorMap.getIndexColorModel();
if (cm != null) {
specifier = IndexedImageTypeSpecifier.createFromIndexColorModel(cm); specifier = IndexedImageTypeSpecifier.createFromIndexColorModel(cm);
break; break;
} }
@ -533,7 +542,8 @@ public class IFFImageReader extends ImageReaderBase {
if (destinationBands != null || offset.x != 0 || offset.y != 0) { if (destinationBands != null || offset.x != 0 || offset.y != 0) {
destination = destination.createWritableChild(0, 0, destination.getWidth(), destination.getHeight(), offset.x, offset.y, destinationBands); destination = destination.createWritableChild(0, 0, destination.getWidth(), destination.getHeight(), offset.x, offset.y, destinationBands);
} }
WritableRaster raster = mImage.getRaster().createCompatibleWritableRaster(width, 1); // WritableRaster raster = mImage.getRaster().createCompatibleWritableRaster(width, 1);
WritableRaster raster = mImage.getRaster().createCompatibleWritableRaster(8 * planeWidth, 1);
Raster sourceRow = raster.createChild(aoi.x, 0, aoi.width, 1, 0, 0, sourceBands); Raster sourceRow = raster.createChild(aoi.x, 0, aoi.width, 1, 0, 0, sourceBands);
final byte[] data = ((DataBufferByte) raster.getDataBuffer()).getData(); final byte[] data = ((DataBufferByte) raster.getDataBuffer()).getData();

View File

@ -57,7 +57,8 @@ class IFFUtil {
0x00000000l << n, 0x00000001l << n, 0x00000100l << n, 0x00000101l << n, 0x00000000l << n, 0x00000001l << n, 0x00000100l << n, 0x00000101l << n,
0x00010000l << n, 0x00010001l << n, 0x00010100l << n, 0x00010101l << n, 0x00010000l << n, 0x00010001l << n, 0x00010100l << n, 0x00010101l << n,
0x01000000l << n, 0x01000001l << n, 0x01000100l << n, 0x01000101l << n, 0x01000000l << n, 0x01000001l << n, 0x01000100l << n, 0x01000101l << n,
0x01010000l << n, 0x01010001l << n, 0x01010100l << n, 0x01010101l << n}; 0x01010000l << n, 0x01010001l << n, 0x01010100l << n, 0x01010101l << n
};
} }
static private final long[][] RTABLE = { static private final long[][] RTABLE = {