java.lang.Object
org.monte.media.ilbm.ILBMDecoder
- All Implemented Interfaces:
IFFVisitor
Creates Image objects by reading an IFF ILBM stream.
ILBM regular expression
ILBM ::= "FORM" #{ "ILBM" BMHD [CMAP] [GRAB] [DEST] [SPRT] [CAMG] CRNG* CCRT* DRNG* [BODY] }
BMHD ::= "BMHD" #{ BitMapHeader }
CMAP ::= "CMAP" #{ (red green blue)* } [0]
GRAB ::= "GRAB" #{ Point2D }
DEST ::= "DEST" #{ DestMerge }
SPRT ::= "SPRT" #{ SpritePrecedence }
CAMG ::= "CAMG" #{ LONG }
CRNG ::= "CRNG" #{ CRange }
DRNG ::= "DRNG" #{ DRange }
CCRT ::= "CCRT" #{ CycleInfo }
BODY ::= "BODY" #{ UBYTE* } [0]
The token "#" represents a ckSize LONG count of the following
braced data bytes. E.g., a BMHD's "#" should equal sizeof(BitMapHeader).
Literal strings are shown in "quotes", [square bracket items] are optional, and
"*" means 0 or more repetitions. A sometimes-needed pad byte is shown as "[0]".- Author:
- Werner Randelshofer, Hausmatt 10, CH-6405 Goldau, Switzerland
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intprotected ArrayList<AmigaBitmapImage>protected static final intprotected intprotected intRaster width and height in pixelsprotected intprotected intNumber of source bitplanes.protected intSource "page" size in pixels.protected intSource "page" size in pixels.protected intTransparent "color number" (sort of).protected intRaster width and height in pixelsprotected intPixel aspect, a ratio width : heightprotected intpixel position for this imageprotected intPixel aspect, a ratio width : heightprotected intpixel position for this imageprotected static final intprotected AmigaBitmapImageBODY dataprotected intCommodore Amiga Graphics Mode.protected static final intprotected intCAMG Video display mode.protected static final intprotected static final intprotected ColorModelCMAP data.protected static final intILBM BMHD chunk: compression algorithm.protected static final intILBM BMHD chunk: compression algorithm.protected static final intILBM BMHD chunk: compression algorithm.protected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intChunk ID's.protected InputStreamInput stream to decode from.protected URLURL to get the input stream from.protected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intILBM CAMG chunk: Mask and ID bits for CAMG ModeID.protected static final intILBM BMHD chunk: masking technique.protected static final intILBM BMHD chunk: masking technique.protected static final intILBM BMHD chunk: masking technique.protected static final intILBM BMHD chunk: masking technique.protected static final intprotected static final intprotected static final intprotected ArrayList<ColorCyclingMemoryImageSource>Stores all the ILBM pictures found during decoding as an instance of ColorCyclingMemoryImageSource.protected static final intprotected static final intprotected static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddecodeBMHD(IFFChunk chunk) protected voiddecodeBODY(IFFChunk chunk) protected voiddecodeCAMG(IFFChunk chunk) Decodes the CAMG Chunk.protected ColorCycledecodeCCRT(IFFChunk chunk) Decodes the color cycling range and timing chunk (ILBM CCRT).protected voiddecodeCMAP(IFFChunk chunk, boolean is4BitsPerChannel) protected ColorCycledecodeCRNG(IFFChunk chunk) Decodes the color range cycling (ILBM CRNG).protected ColorCycledecodeDRNG(IFFChunk chunk) Decodes the DPaint IV enhanced color cycle chunk (ILBM DRNG)voidenterGroup(IFFChunk chunk) voidleaveGroup(IFFChunk chunk) produce()Processes the input stream and creates a vector of ColorCyclingMemoryImageSource instances.Processes the input stream and creates a vector of BitmapImages instances.voidregisterChunks(IFFParser iff) static intunpackByteRun1(byte[] in, byte[] out) ByteRun1 run decoder.voidunpackVertical(byte[] in, AmigaBitmapImage bm) Vertical run decoder.voidvisitChunk(IFFChunk group, IFFChunk chunk)
-
Field Details
-
ILBM_ID
protected static final int ILBM_IDChunk ID's. -
BMHD_ID
protected static final int BMHD_ID -
CMAP_ID
protected static final int CMAP_ID -
CAMG_ID
protected static final int CAMG_ID -
CCRT_ID
protected static final int CCRT_ID -
CRNG_ID
protected static final int CRNG_ID -
DRNG_ID
protected static final int DRNG_ID -
BODY_ID
protected static final int BODY_ID -
VDAT_ID
protected static final int VDAT_ID -
MONITOR_ID_MASK
protected static final int MONITOR_ID_MASKILBM CAMG chunk: Mask and ID bits for CAMG ModeID.- See Also:
-
DEFAULT_MONITOR_ID
protected static final int DEFAULT_MONITOR_ID- See Also:
-
NTSC_MONITOR_ID
protected static final int NTSC_MONITOR_ID- See Also:
-
PAL_MONITOR_ID
protected static final int PAL_MONITOR_ID- See Also:
-
VGA_MONITOR_ID
protected static final int VGA_MONITOR_ID- See Also:
-
A2024_MONITOR_ID
protected static final int A2024_MONITOR_ID- See Also:
-
PROTO_MONITOR_ID
protected static final int PROTO_MONITOR_ID- See Also:
-
EURO72_MONITOR_ID
protected static final int EURO72_MONITOR_ID- See Also:
-
EURO36_MONITOR_ID
protected static final int EURO36_MONITOR_ID- See Also:
-
SUPER72_MONITOR_ID
protected static final int SUPER72_MONITOR_ID- See Also:
-
DBLNTSC_MONITOR_ID
protected static final int DBLNTSC_MONITOR_ID- See Also:
-
DBLPAL_MONITOR_ID
protected static final int DBLPAL_MONITOR_ID- See Also:
-
MODE_INDEXED_COLORS
protected static final int MODE_INDEXED_COLORS- See Also:
-
MODE_DIRECT_COLORS
protected static final int MODE_DIRECT_COLORS- See Also:
-
MODE_EHB
protected static final int MODE_EHB- See Also:
-
MODE_HAM6
protected static final int MODE_HAM6- See Also:
-
MODE_HAM8
protected static final int MODE_HAM8- See Also:
-
HAM_MASK
protected static final int HAM_MASK- See Also:
-
EHB_MASK
protected static final int EHB_MASK- See Also:
-
HAM_KEY
protected static final int HAM_KEY- See Also:
-
EXTRAHALFBRITE_KEY
protected static final int EXTRAHALFBRITE_KEY- See Also:
-
MSK_NONE
protected static final int MSK_NONEILBM BMHD chunk: masking technique.- See Also:
-
MSK_HAS_MASK
protected static final int MSK_HAS_MASKILBM BMHD chunk: masking technique.- See Also:
-
MSK_HAS_TRANSPARENT_COLOR
protected static final int MSK_HAS_TRANSPARENT_COLORILBM BMHD chunk: masking technique.- See Also:
-
MSK_LASSO
protected static final int MSK_LASSOILBM BMHD chunk: masking technique.- See Also:
-
CMP_NONE
protected static final int CMP_NONEILBM BMHD chunk: compression algorithm.- See Also:
-
CMP_BYTE_RUN_1
protected static final int CMP_BYTE_RUN_1ILBM BMHD chunk: compression algorithm.- See Also:
-
CMP_VERTICAL
protected static final int CMP_VERTICALILBM BMHD chunk: compression algorithm.- See Also:
-
inputStream
Input stream to decode from. -
location
URL to get the input stream from. -
sources
Stores all the ILBM pictures found during decoding as an instance of ColorCyclingMemoryImageSource. -
bitmapSources
-
bmhdWidth
protected int bmhdWidthRaster width and height in pixels -
bmhdHeight
protected int bmhdHeightRaster width and height in pixels -
bmhdXPosition
protected int bmhdXPositionpixel position for this image -
bmhdYPosition
protected int bmhdYPositionpixel position for this image -
bmhdNbPlanes
protected int bmhdNbPlanesNumber of source bitplanes. -
bmhdMasking
protected int bmhdMasking -
bmhdCompression
protected int bmhdCompression -
bmhdTransparentColor
protected int bmhdTransparentColorTransparent "color number" (sort of). -
bmhdXAspect
protected int bmhdXAspectPixel aspect, a ratio width : height -
bmhdYAspect
protected int bmhdYAspectPixel aspect, a ratio width : height -
bmhdPageWidth
protected int bmhdPageWidthSource "page" size in pixels. -
bmhdPageHeight
protected int bmhdPageHeightSource "page" size in pixels. -
camg
protected int camgCommodore Amiga Graphics Mode. -
camgMode
protected int camgModeCAMG Video display mode. -
cmapColorModel
CMAP data. -
bodyBitmap
BODY data
-
-
Constructor Details
-
ILBMDecoder
Constructors -
ILBMDecoder
-
-
Method Details
-
produce
Processes the input stream and creates a vector of ColorCyclingMemoryImageSource instances.- Returns:
- A vector of java.awt.img.ColorCyclingMemoryImageSource.
- Throws:
IOException
-
produceBitmaps
Processes the input stream and creates a vector of BitmapImages instances.- Returns:
- A vector of java.awt.img.ColorCyclingMemoryImageSource.
- Throws:
IOException
-
registerChunks
-
enterGroup
- Specified by:
enterGroupin interfaceIFFVisitor
-
leaveGroup
- Specified by:
leaveGroupin interfaceIFFVisitor
-
visitChunk
- Specified by:
visitChunkin interfaceIFFVisitor- Throws:
ParseExceptionAbortException
-
decodeBMHD
- Throws:
ParseException
-
decodeCAMG
Decodes the CAMG Chunk. Requires data from BMHD Chunk.- Throws:
ParseException
-
decodeCMAP
- Throws:
ParseException
-
decodeCCRT
Decodes the color cycling range and timing chunk (ILBM CCRT).enum { dontCycle = 0, forward = 1, backwards = -1 } ccrtDirection; typedef struct { WORD enum ccrtDirection direction; // 0=don't cycle, 1=forward, -1=backwards UBYTE start; // range lower UBYTE end; // range upper ULONG seconds; // seconds between cycling ULONG microseconds; // msecs between cycling WORD pad; // future exp - store 0 here } ilbmColorCyclingRangeAndTimingChunk;- Throws:
ParseException
-
decodeCRNG
Decodes the color range cycling (ILBM CRNG).#define RNG_NORATE 36 // Dpaint uses this rate to mean non-active set { active = 1, reverse = 2 } crngActive; // A CRange is store in a CRNG chunk. typedef struct { WORD pad1; // reserved for future use; store 0 here * WORD rate; // 60/sec=16384, 30/sec=8192, 1/sec=16384/60=273 WORD set crngActive flags; // bit0 set = active, bit 1 set = reverse UBYTE low; UBYTE high; // lower and upper color registers selected } ilbmColorRegisterRangeChunk;- Throws:
ParseException
-
decodeDRNG
Decodes the DPaint IV enhanced color cycle chunk (ILBM DRNG)The RNG_ACTIVE flag is set when the range is cyclable. A range should only have the RNG _ACTIVE if it:
- contains at least one color register
- has a defined rate
- has more than one color and/or color register
ILBM DRNG DPaint IV enhanced color cycle chunk -------------------------------------------- set { RNG_ACTIVE=1,RNG_DP_RESERVED=4 } drngFlags; /* True color cell * / typedef struct { UBYTE cell; UBYTE r; UBYTE g; UBYTE b; } ilbmDRNGDColor; /* Color register cell * / typedef struct { UBYTE cell; UBYTE index; } ilbmDRNGDIndex; /* DRNG chunk. * / typedef struct { UBYTE min; /* min cell value * / UBYTE max; /* max cell value * / UWORD rate; /* color cycling rate, 16384 = 60 steps/second * / UWORD set drngFlags flags; /* 1=RNG_ACTIVE, 4=RNG_DP_RESERVED * / UBYTE ntrue; /* number of DColorCell structs to follow * / UBYTE ntregs; /* number of DIndexCell structs to follow * / ilbmDRNGDColor[ntrue] trueColorCells; ilbmDRNGDIndex[ntregs] colorRegisterCells; } ilbmDRangeChunk;- Throws:
ParseException
-
decodeBODY
- Throws:
ParseException
-
unpackByteRun1
ByteRun1 run decoder.The run encoding scheme by byteRun1 is best described by pseudo code for the decoder Unpacker (called UnPackBits in the Macintosh toolbox.
UnPacker: LOOP until produced the desired number of bytes Read the next source byte into n SELECT n FROM [0..127] => copy the next n+1 bytes literally [-1..-127] => replicate the next byte -n+1 times -128 => no operation ENDCASE; ENDLOOP;- Parameters:
in-out-- Throws:
ParseException
-
unpackVertical
Vertical run decoder.Each plane is stored in a separate VDAT chunk.
A VDAT chunk consists of an id, a length, and a body.
struct { uint16 id; // The 4 ASCII characters "VDAT" uint16 length, byte[length] body }The body consists of a command list and a data list.struct { uint16 cnt; // Command count + 2 uint8[cnt - 2] cmd; // The commands uint16[] data; // Data words }Pseudo code for the unpacker:UnPacker: Read cnt; LOOP cnt - 2 TIMES Read the next command byte into cmd SELECT cmd FROM 0 => Read the next data word into n Copy the next n data words literally 1 => Read the next data word into n Replicate the next data word n times [2..127] => Replicate the next data word cmd times [-1..-128] => Copy the next -cmd data words literally ENDCASE; IF end of data reached THEN EXIT END; ENDLOOP;- Throws:
ParseException
-