public class ILBMDecoder extends java.lang.Object implements IFFVisitor
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]".Modifier and Type | Field and Description |
---|---|
protected static int |
A2024_MONITOR_ID |
protected java.util.ArrayList<BitmapImage> |
bitmapSources |
protected static int |
BMHD_ID |
protected int |
bmhdCompression |
protected int |
bmhdHeight
Raster width_ and heigth in pixels
|
protected int |
bmhdMasking |
protected int |
bmhdNbPlanes
Number of source bitplanes.
|
protected int |
bmhdPageHeight
Source "page" size in pixels.
|
protected int |
bmhdPageWidth
Source "page" size in pixels.
|
protected int |
bmhdTransparentColor
Transparent "color number" (sort of).
|
protected int |
bmhdWidth
Raster width_ and heigth in pixels
|
protected int |
bmhdXAspect
Pixel aspect, a ratio width : height
|
protected int |
bmhdXPosition
pixel position for this image
|
protected int |
bmhdYAspect
Pixel aspect, a ratio width : height
|
protected int |
bmhdYPosition
pixel position for this image
|
protected static int |
BODY_ID |
protected BitmapImage |
bodyBitmap
BODY data
|
protected int |
camg
Commodore Amiga Graphics Mode.
|
protected static int |
CAMG_ID |
protected int |
camgMode
CAMG Video display mode.
|
protected static int |
CCRT_ID |
protected static int |
CMAP_ID |
protected java.awt.image.ColorModel |
cmapColorModel
CMAP data.
|
protected static int |
CMP_BYTE_RUN_1
ILBM BMHD chunk: compression algorithm.
|
protected static int |
CMP_NONE
ILBM BMHD chunk: compression algorithm.
|
protected static int |
CMP_VERTICAL
ILBM BMHD chunk: compression algorithm.
|
protected static int |
CRNG_ID |
protected static int |
DBLNTSC_MONITOR_ID |
protected static int |
DBLPAL_MONITOR_ID |
protected static int |
DEFAULT_MONITOR_ID |
protected static int |
DRNG_ID |
protected static int |
EHB_MASK |
protected static int |
EURO36_MONITOR_ID |
protected static int |
EURO72_MONITOR_ID |
protected static int |
EXTRAHALFBRITE_KEY |
protected static int |
HAM_KEY |
protected static int |
HAM_MASK |
protected static int |
ILBM_ID
Chunk ID's.
|
protected java.io.InputStream |
inputStream
Input stream to decode from.
|
protected java.net.URL |
location
URL to get the input stream from.
|
protected static int |
MODE_DIRECT_COLORS |
protected static int |
MODE_EHB |
protected static int |
MODE_HAM6 |
protected static int |
MODE_HAM8 |
protected static int |
MODE_INDEXED_COLORS |
protected static int |
MONITOR_ID_MASK
ILBM CAMG chunk: Mask and ID bits for CAMG ModeID.
|
protected static int |
MSK_HAS_MASK
ILBM BMHD chunk: masking technique.
|
protected static int |
MSK_HAS_TRANSPARENT_COLOR
ILBM BMHD chunk: masking technique.
|
protected static int |
MSK_LASSO
ILBM BMHD chunk: masking technique.
|
protected static int |
MSK_NONE
ILBM BMHD chunk: masking technique.
|
protected static int |
NTSC_MONITOR_ID |
protected static int |
PAL_MONITOR_ID |
protected java.util.Hashtable |
properties
Properties.
|
protected static int |
PROTO_MONITOR_ID |
protected java.util.ArrayList<ColorCyclingMemoryImageSource> |
sources
Stores all the ILBM pictures found during decoding
as an instance of ColorCyclingMemoryImageSource.
|
protected static int |
SUPER72_MONITOR_ID |
protected static int |
VDAT_ID |
protected static int |
VGA_MONITOR_ID |
Constructor and Description |
---|
ILBMDecoder(java.io.InputStream in)
Constructors
|
ILBMDecoder(java.net.URL location) |
Modifier and Type | Method and Description |
---|---|
protected void |
decodeBMHD(IFFChunk chunk) |
protected void |
decodeBODY(IFFChunk chunk) |
protected void |
decodeCAMG(IFFChunk chunk)
Decodes the CAMG Chunk.
|
protected ColorCycle |
decodeCCRT(IFFChunk chunk)
Decodes the color cycling range and timing chunk (ILBM CCRT).
|
protected void |
decodeCMAP(IFFChunk chunk,
boolean is4BitsPerChannel) |
protected ColorCycle |
decodeCRNG(IFFChunk chunk)
Decodes the color range cycling (ILBM CRNG).
|
protected ColorCycle |
decodeDRNG(IFFChunk chunk)
Decodes the DPaint IV enhanced color cycle chunk (ILBM DRNG)
|
void |
enterGroup(IFFChunk chunk) |
void |
leaveGroup(IFFChunk chunk) |
java.util.ArrayList<ColorCyclingMemoryImageSource> |
produce()
Processes the input stream and creates a vector of
ColorCyclingMemoryImageSource instances.
|
java.util.ArrayList<BitmapImage> |
produceBitmaps()
Processes the input stream and creates a vector of
BitmapImages instances.
|
void |
registerChunks(IFFParser iff) |
static int |
unpackByteRun1(byte[] in,
byte[] out)
ByteRun1 run decoder.
|
void |
unpackVertical(byte[] in,
BitmapImage bm)
Vertical run decoder.
|
void |
visitChunk(IFFChunk group,
IFFChunk chunk) |
protected static final int ILBM_ID
protected static final int BMHD_ID
protected static final int CMAP_ID
protected static final int CAMG_ID
protected static final int CCRT_ID
protected static final int CRNG_ID
protected static final int DRNG_ID
protected static final int BODY_ID
protected static final int VDAT_ID
protected static final int MONITOR_ID_MASK
protected static final int DEFAULT_MONITOR_ID
protected static final int NTSC_MONITOR_ID
protected static final int PAL_MONITOR_ID
protected static final int VGA_MONITOR_ID
protected static final int A2024_MONITOR_ID
protected static final int PROTO_MONITOR_ID
protected static final int EURO72_MONITOR_ID
protected static final int EURO36_MONITOR_ID
protected static final int SUPER72_MONITOR_ID
protected static final int DBLNTSC_MONITOR_ID
protected static final int DBLPAL_MONITOR_ID
protected static final int MODE_INDEXED_COLORS
protected static final int MODE_DIRECT_COLORS
protected static final int MODE_EHB
protected static final int MODE_HAM6
protected static final int MODE_HAM8
protected static final int HAM_MASK
protected static final int EHB_MASK
protected static final int HAM_KEY
protected static final int EXTRAHALFBRITE_KEY
protected static final int MSK_NONE
protected static final int MSK_HAS_MASK
protected static final int MSK_HAS_TRANSPARENT_COLOR
protected static final int MSK_LASSO
protected static final int CMP_NONE
protected static final int CMP_BYTE_RUN_1
protected static final int CMP_VERTICAL
protected java.io.InputStream inputStream
protected java.net.URL location
protected java.util.ArrayList<ColorCyclingMemoryImageSource> sources
protected java.util.ArrayList<BitmapImage> bitmapSources
protected java.util.Hashtable properties
protected int bmhdWidth
protected int bmhdHeight
protected int bmhdXPosition
protected int bmhdYPosition
protected int bmhdNbPlanes
protected int bmhdMasking
protected int bmhdCompression
protected int bmhdTransparentColor
protected int bmhdXAspect
protected int bmhdYAspect
protected int bmhdPageWidth
protected int bmhdPageHeight
protected int camg
protected int camgMode
protected java.awt.image.ColorModel cmapColorModel
protected BitmapImage bodyBitmap
public ILBMDecoder(java.io.InputStream in)
public ILBMDecoder(java.net.URL location)
public java.util.ArrayList<ColorCyclingMemoryImageSource> produce() throws java.io.IOException
java.io.IOException
public java.util.ArrayList<BitmapImage> produceBitmaps() throws java.io.IOException
java.io.IOException
public void registerChunks(IFFParser iff)
public void enterGroup(IFFChunk chunk)
enterGroup
in interface IFFVisitor
public void leaveGroup(IFFChunk chunk)
leaveGroup
in interface IFFVisitor
public void visitChunk(IFFChunk group, IFFChunk chunk) throws ParseException, AbortException
visitChunk
in interface IFFVisitor
ParseException
AbortException
protected void decodeBMHD(IFFChunk chunk) throws ParseException
ParseException
protected void decodeCAMG(IFFChunk chunk) throws ParseException
ParseException
protected void decodeCMAP(IFFChunk chunk, boolean is4BitsPerChannel) throws ParseException
ParseException
protected ColorCycle decodeCCRT(IFFChunk chunk) throws ParseException
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;
ParseException
protected ColorCycle decodeCRNG(IFFChunk chunk) throws ParseException
#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;
ParseException
protected ColorCycle decodeDRNG(IFFChunk chunk) throws ParseException
The RNG_ACTIVE flag is set when the range is cyclable. A range should only have the RNG _ACTIVE if it:
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;
ParseException
protected void decodeBODY(IFFChunk chunk) throws ParseException
ParseException
public static int unpackByteRun1(byte[] in, byte[] out) throws ParseException
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;
in
- out
- ParseException
public void unpackVertical(byte[] in, BitmapImage bm) throws ParseException
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;
ParseException