net.sourceforge.jiu.codecs

Class 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.

Usage example

 IFFCodec codec = new IFFCodec();
 codec.setFile("image.iff", CodecMode.LOAD);
 codec.process();
 PixelImage image = codec.getImage();
 
Author:
Marco Schmidt
Since:
0.3.0

Field Summary

private static byte
COMPRESSION_NONE
private static byte
COMPRESSION_RLE
private static int
MAGIC_BMHD
private static int
MAGIC_BODY
private static int
MAGIC_CAMG
private static int
MAGIC_CMAP
private static int
MAGIC_FORM
private static int
MAGIC_ILBM
private static int
MAGIC_PBM
private static int
SIZE_BMHD
private int
camg
private byte
compression
private boolean
ehb
private boolean
ham
private boolean
ham6
private boolean
ham8
private int
height
private int
numPlanes
private Palette
palette
private boolean
rgb24
private int
type
private int
width

Fields inherited from class net.sourceforge.jiu.codecs.ImageCodec

boundsAvail, boundsHeight, boundsWidth, boundsX1, boundsX2, boundsY1, boundsY2, comments, din, dout, dpiX, dpiY, image, imageIndex, in, mode, out, raf

Fields inherited from class net.sourceforge.jiu.ops.Operation

abort, progressListeners

Method Summary

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, getFileExtensions, getFormatName, getImage, getImageIndex, getInputAsDataInput, getInputStream, getMimeTypes, getMode, getNumComments, getOutputAsDataOutput, getOutputStream, getRandomAccessFile, hasBounds, initModeFromIOObjects, isLoadingSupported, isRowRequired, isSavingSupported, 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, process, removeProgressListener, setAbort, setProgress, setProgress

Field Details

COMPRESSION_NONE

private static final byte COMPRESSION_NONE
Field Value:
0

COMPRESSION_RLE

private static final byte COMPRESSION_RLE
Field Value:
1

MAGIC_BMHD

private static final int MAGIC_BMHD
Field Value:
1112361028

MAGIC_BODY

private static final int MAGIC_BODY
Field Value:
1112491097

MAGIC_CAMG

private static final int MAGIC_CAMG
Field Value:
1128353095

MAGIC_CMAP

private static final int MAGIC_CMAP
Field Value:
1129136464

MAGIC_FORM

private static final int MAGIC_FORM
Field Value:
1179603533

MAGIC_ILBM

private static final int MAGIC_ILBM
Field Value:
1229734477

MAGIC_PBM

private static final int MAGIC_PBM
Field Value:
1346522400

SIZE_BMHD

private static final int SIZE_BMHD
Field Value:
20

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

Method Details

checkAndLoad

private void checkAndLoad()
            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 -

createExtraHalfbritePalette

private void createExtraHalfbritePalette()

getChunkName

private static String getChunkName(int name)

getFileExtensions

public String[] getFileExtensions()
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 interface ImageCodec
Returns:
String array with typical file extensions

getFormatName

public String getFormatName()
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).
Overrides:
getFormatName in interface ImageCodec
Returns:
name of the file format supported by this codec

getMimeTypes

public String[] getMimeTypes()
Return the MIME (Multipurpose Internet Mail Extensions) type strings for this format, or null if none are available.
Overrides:
getMimeTypes in interface ImageCodec
Returns:
MIME type strings or null

isLoadingSupported

public boolean isLoadingSupported()
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.
Overrides:
isLoadingSupported in interface ImageCodec
Returns:
if loading is supported

isSavingSupported

public boolean isSavingSupported()
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.
Overrides:
isSavingSupported in interface 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.

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.

process

public void process()
            throws InvalidFileStructureException,
                   MissingParameterException,
                   OperationFailedException,
                   UnsupportedTypeException,
                   WrongFileFormatException
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 interface Operation
Throws:
MissingParameterException - if any mandatory parameter was not given to the operation
OperationFailedException -