Package net.sourceforge.jiu.codecs

# Class IFFCodec

java.lang.Object
net.sourceforge.jiu.ops.Operation
net.sourceforge.jiu.codecs.ImageCodec
net.sourceforge.jiu.codecs.IFFCodec

public class IFFCodec extends ImageCodec
A codec to read Amiga IFF image files. IFF (Interchange File Format) is an Amiga wrapper file format for texts, images, animations, sound and other kinds of data. This codec only deals with image IFF files. Typical file extensions for IFF image files are `.lbm` and `.iff`.

### Loading / saving

Only loading is supported by this codec.

### Supported file types

Both uncompressed and run-length encoded files are read.

- 1 to 8 bit indexed (paletted) color
- 24 bit RGB truecolor
- HAM6 and HAM8 images (which are a mixture of paletted and truecolor)

### Usage example

     IFFCodec codec = new IFFCodec();
     codec.setFile("image.iff", CodecMode.LOAD);
     codec.process();
     PixelImage image = codec.getImage();

Since:
  0.3.0
Author:
  Marco Schmidt

## Field Summary

Fields
Modifier and Type
Field
Description
`private int`
`camg`
`private byte`
`compression`
`private static final byte`
`COMPRESSION_NONE`
`private static final byte`
`COMPRESSION_RLE`
`private boolean`
`ehb`
`private boolean`
`ham`
`private boolean`
`ham6`
`private boolean`
`ham8`
`private int`
`height`
`private static final int`
`MAGIC_BMHD`
`private static final int`
`MAGIC_BODY`
`private static final int`
`MAGIC_CAMG`
`private static final int`
`MAGIC_CMAP`
`private static final int`
`MAGIC_FORM`
`private static final int`
`MAGIC_ILBM`
`private static final int`
`MAGIC_PBM`
`private int`
`numPlanes`
`private Palette`
`palette`
`private boolean`
`rgb24`
`private static final int`
`SIZE_BMHD`
`private int`
`type`
`private int`
`width`

## Constructor Summary

Constructors
Constructor
Description
`IFFCodec()`

## Method Summary

Modifier and Type
Method
Description
`private void`
`checkAndLoad()`
`private void`
`convertRow(byte[][] sourcePlaneData, byte[][] dest)`
Converts input planes to index or truecolor output values.
`private void`
`createExtraHalfbritePalette()`
`private static String`
`getChunkName(int name)`
`String[]`
`getFileExtensions()`
Returns all file extensions that are typical for this file format.
`String`
`getFormatName()`
Returns the name of the file format supported by this codec.
`String[]`
`getMimeTypes()`
Return the MIME (Multipurpose Internet Mail Extensions) type strings for this format, or `null` if none are available.
`boolean`
`isLoadingSupported()`
Returns if this codec is able to load images in the file format supported by this codec.
`boolean`
`isSavingSupported()`
Returns if this codec is able to save images in the file format supported by this codec.
`private void`
`loadBytes(DataInput in, byte[] data, int num, int y)`
Loads data.length bytes from the input stream to the data array, regarding the compression type.
`private PixelImage`
`loadImage(DataInput in)`
Loads an image from given input stream in, regarding the compression type.
`void`
`process()`
This method does the actual work of the operation.

### Methods inherited from class net.sourceforge.jiu.codecs.ImageCodec

`appendComment, checkBounds, checkImageResolution, close, getBoundsHeight, getBoundsWidth, getBoundsX1, getBoundsX2, getBoundsY1, getBoundsY2, getComment, getDataInput, getDataOutput, getDpiX, getDpiY, getImage, getImageIndex, getInputAsDataInput, getInputStream, getMode, getNumComments, getOutputAsDataOutput, getOutputStream, getRandomAccessFile, hasBounds, initModeFromIOObjects, isRowRequired, isTileRequired, removeAllComments, removeBounds, setBounds, setBoundsIfNecessary, setDataInput, setDataOutput, setDpi, setFile, setFile, setImage, setImageIndex, setInputStream, setOutputStream, setRandomAccessFile, suggestFileExtension`

### Methods inherited from class net.sourceforge.jiu.ops.Operation

`addProgressListener, addProgressListeners, getAbort, removeProgressListener, setAbort, setProgress, setProgress`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### MAGIC_BMHD

private static final int MAGIC_BMHD

See Also:
  - Constant Field Values

### MAGIC_BODY

private static final int MAGIC_BODY

See Also:
  - Constant Field Values

### MAGIC_CMAP

private static final int MAGIC_CMAP

See Also:
  - Constant Field Values

### MAGIC_CAMG

private static final int MAGIC_CAMG

See Also:
  - Constant Field Values

### MAGIC_FORM

private static final int MAGIC_FORM

See Also:
  - Constant Field Values

### MAGIC_ILBM

private static final int MAGIC_ILBM

See Also:
  - Constant Field Values

### MAGIC_PBM

private static final int MAGIC_PBM

See Also:
  - Constant Field Values

### SIZE_BMHD

private static final int SIZE_BMHD

See Also:
  - Constant Field Values

### COMPRESSION_NONE

private static final byte COMPRESSION_NONE

See Also:
  - Constant Field Values

### COMPRESSION_RLE

private static final byte COMPRESSION_RLE

See Also:
  - Constant Field Values

### camg

private int camg

### compression

private byte compression

### ehb

private boolean ehb

### ham

private boolean ham

### ham6

private boolean ham6

### ham8

private boolean ham8

### height

private int height

### numPlanes

private int numPlanes

### palette

private Palette palette

### rgb24

private boolean rgb24

### type

private int type

### width

private int width

## Constructor Details

### IFFCodec

public IFFCodec()

## Method Details

### checkAndLoad

private void checkAndLoad() throws InvalidFileStructureException, IOException, MissingParameterException, UnsupportedTypeException, WrongFileFormatException, WrongParameterException

Throws:
  `InvalidFileStructureException`
  `IOException`
  `MissingParameterException`
  `UnsupportedTypeException`
  `WrongFileFormatException`
  `WrongParameterException`

### convertRow

private void convertRow(byte[][] sourcePlaneData, byte[][] dest)
Converts input planes to index or truecolor output values. Exact interpretation depends on the type of ILBM image storage:

- normal mode; the 1 to 8 planes create index values which are used with the colormap
- RGB24; each of the 24 planes adds one bit to the three intensity values for red, green and blue; no color map is necessary
- HAM6; a six bit integer (0 to 63) is assembled from the planes and the top two bits determine if the previous color is modified or if the lower four bits are used as an index into the palette (which has consequently 24 = 16 entries

Parameters:
  `dest` -
  `sourcePlanes` -

### createExtraHalfbritePalette

private void createExtraHalfbritePalette()

### getChunkName

private static String getChunkName(int name)

### getFileExtensions

public String[] getFileExtensions()
Description copied from class: `ImageCodec`
Returns all file extensions that are typical for this file format. The default implementation in ImageCodec returns `null`. The file extension strings should include a leading dot and are supposed to be lower case (if that is allowed for the given file format). Example: `{".jpg", ".jpeg"}` for the JPEG file format.

Overrides:
  `getFileExtensions` in class `ImageCodec`
Returns:
  String array with typical file extensions

### getFormatName

public String getFormatName()
Description copied from class: `ImageCodec`
Returns the name of the file format supported by this codec. All classes extending `ImageCodec` must override this method. When overriding, leave out any words in a particular language so that this format name can be understood by everyone. Usually it is enough to return the format creator plus a typical abbreviation, e.g. `Microsoft BMP` or `Portable Anymap (PNM)`.

Specified by:
  `getFormatName` in class `ImageCodec`
Returns:
  name of the file format supported by this codec

### getMimeTypes

public String[] getMimeTypes()
Description copied from class: `ImageCodec`
Return the MIME (Multipurpose Internet Mail Extensions) type strings for this format, or `null` if none are available.

Specified by:
  `getMimeTypes` in class `ImageCodec`
Returns:
  MIME type strings or null

### isLoadingSupported

public boolean isLoadingSupported()
Description copied from class: `ImageCodec`
Returns if this codec is able to load images in the file format supported by this codec. If `true` is returned this does not necessarily mean that all files in this format can be read, but at least some.

Specified by:
  `isLoadingSupported` in class `ImageCodec`
Returns:
  if loading is supported

### isSavingSupported

public boolean isSavingSupported()
Description copied from class: `ImageCodec`
Returns if this codec is able to save images in the file format supported by this codec. If `true` is returned this does not necessarily mean that all types files in this format can be written, but at least some.

Specified by:
  `isSavingSupported` in class `ImageCodec`
Returns:
  if saving is supported

### loadBytes

private void loadBytes(DataInput in, byte[] data, int num, int y) throws InvalidFileStructureException, IOException
Loads data.length bytes from the input stream to the data array, regarding the compression type. COMPRESSION_NONE will make this method load data.length bytes from the input stream. COMPRESSION_RLE will make this method decompress data.length bytes from input.

Throws:
  `InvalidFileStructureException`
  `IOException`

### loadImage

private PixelImage loadImage(DataInput in) throws InvalidFileStructureException, IOException, UnsupportedTypeException, WrongParameterException
Loads an image from given input stream in, regarding the compression type. The image will have 1 to 8 or 24 planes, a resolution given by the dimension width times height. The color map data will be used to convert index values to RGB pixels. Returns the resulting image. Will throw an IOException if either there were errors reading from the input stream or if the file does not exactly match the file format.

Throws:
  `InvalidFileStructureException`
  `IOException`
  `UnsupportedTypeException`
  `WrongParameterException`

### process

public void process() throws InvalidFileStructureException, MissingParameterException, OperationFailedException, UnsupportedTypeException, WrongFileFormatException
Description copied from class: `Operation`
This method does the actual work of the operation. It must be called after all parameters have been given to the operation object.

Overrides:
  `process` in class `Operation`
Throws:
  `MissingParameterException` - if any mandatory parameter was not given to the operation
  `OperationFailedException`
  `InvalidFileStructureException`
  `UnsupportedTypeException`
  `WrongFileFormatException`