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()
String
getFormatName()
String[]
getMimeTypes()
boolean
isLoadingSupported()
boolean
isSavingSupported()
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()

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()
Overrides:
getFileExtensions in interface ImageCodec

getFormatName

public String getFormatName()
Overrides:
getFormatName in interface ImageCodec

getMimeTypes

public String[] getMimeTypes()
Overrides:
getMimeTypes in interface ImageCodec

isLoadingSupported

public boolean isLoadingSupported()
Overrides:
isLoadingSupported in interface ImageCodec

isSavingSupported

public boolean isSavingSupported()
Overrides:
isSavingSupported in interface ImageCodec

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
Overrides:
process in interface Operation