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
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
FieldsModifier and TypeFieldDescriptionprivate intprivate byteprivate static final byteprivate static final byteprivate booleanprivate booleanprivate booleanprivate booleanprivate intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate intprivate Paletteprivate booleanprivate static final intprivate intprivate int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidprivate voidconvertRow(byte[][] sourcePlaneData, byte[][] dest) Converts input planes to index or truecolor output values.private voidprivate static StringgetChunkName(int name) String[]Returns all file extensions that are typical for this file format.Returns the name of the file format supported by this codec.String[]Return the MIME (Multipurpose Internet Mail Extensions) type strings for this format, ornullif none are available.booleanReturns if this codec is able to load images in the file format supported by this codec.booleanReturns if this codec is able to save images in the file format supported by this codec.private voidLoads data.length bytes from the input stream to the data array, regarding the compression type.private PixelImageLoads an image from given input stream in, regarding the compression type.voidprocess()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, suggestFileExtensionMethods inherited from class net.sourceforge.jiu.ops.Operation
addProgressListener, addProgressListeners, getAbort, removeProgressListener, setAbort, setProgress, setProgress
-
Field Details
-
MAGIC_BMHD
private static final int MAGIC_BMHD- See Also:
-
MAGIC_BODY
private static final int MAGIC_BODY- See Also:
-
MAGIC_CMAP
private static final int MAGIC_CMAP- See Also:
-
MAGIC_CAMG
private static final int MAGIC_CAMG- See Also:
-
MAGIC_FORM
private static final int MAGIC_FORM- See Also:
-
MAGIC_ILBM
private static final int MAGIC_ILBM- See Also:
-
MAGIC_PBM
private static final int MAGIC_PBM- See Also:
-
SIZE_BMHD
private static final int SIZE_BMHD- See Also:
-
COMPRESSION_NONE
private static final byte COMPRESSION_NONE- See Also:
-
COMPRESSION_RLE
private static final byte COMPRESSION_RLE- See Also:
-
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
-
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 -
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:
sourcePlanes-dest-
-
createExtraHalfbritePalette
private void createExtraHalfbritePalette() -
getChunkName
-
getFileExtensions
Description copied from class:ImageCodecReturns all file extensions that are typical for this file format. The default implementation in ImageCodec returnsnull. 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:
getFileExtensionsin classImageCodec- Returns:
- String array with typical file extensions
-
getFormatName
Description copied from class:ImageCodecReturns the name of the file format supported by this codec. All classes extendingImageCodecmust 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 BMPorPortable Anymap (PNM).- Specified by:
getFormatNamein classImageCodec- Returns:
- name of the file format supported by this codec
-
getMimeTypes
Description copied from class:ImageCodecReturn the MIME (Multipurpose Internet Mail Extensions) type strings for this format, ornullif none are available.- Specified by:
getMimeTypesin classImageCodec- Returns:
- MIME type strings or null
-
isLoadingSupported
public boolean isLoadingSupported()Description copied from class:ImageCodecReturns if this codec is able to load images in the file format supported by this codec. Iftrueis returned this does not necessarily mean that all files in this format can be read, but at least some.- Specified by:
isLoadingSupportedin classImageCodec- Returns:
- if loading is supported
-
isSavingSupported
public boolean isSavingSupported()Description copied from class:ImageCodecReturns if this codec is able to save images in the file format supported by this codec. Iftrueis returned this does not necessarily mean that all types files in this format can be written, but at least some.- Specified by:
isSavingSupportedin classImageCodec- 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, WrongFileFormatExceptionDescription copied from class:OperationThis method does the actual work of the operation. It must be called after all parameters have been given to the operation object.- Overrides:
processin classOperation- Throws:
MissingParameterException- if any mandatory parameter was not given to the operationWrongParameterException- if at least one of the input parameters was not initialized appropriately (values out of the valid interval, etc.)OperationFailedExceptionInvalidFileStructureExceptionUnsupportedTypeExceptionWrongFileFormatException
-