net.sourceforge.jiu.codecs

Class PSDCodec


public class PSDCodec
extends ImageCodec

A codec to read images from Photoshop PSD files. PSD was created by Adobe for their Photoshop image editing software. Note that only a small subset of valid PSD files is supported by this codec. Typical file extension is .psd.
Author:
Marco Schmidt

Field Summary

private static int
COLOR_MODE_GRAYSCALE
private static int
COLOR_MODE_INDEXED
private static int
COLOR_MODE_RGB_TRUECOLOR
private static short
COMPRESSION_NONE
private static short
COMPRESSION_PACKBITS
private static int
MAGIC_8BPS
private int
channels
private int
colorMode
private short
compression
private int
depth
private Gray8Image
gray8Image
private int
height
private DataInput
in
private int
magic
private Palette
palette
private Paletted8Image
paletted8Image
private RGB24Image
rgb24Image
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
allocate()
private static String
getColorTypeName(int colorMode)
String
getFormatName()
String[]
getMimeTypes()
boolean
isLoadingSupported()
boolean
isSavingSupported()
private void
load()
Attempts to load an Image from argument stream in (which could, as an example, be a RandomAccessFile instance, it implements the DataInput interface).
private void
loadHeader()
Reads the PSD header to private members of this class instance.
private void
loadImageData()
private void
loadPackbitsCompressedData(byte[] data, int offset, int num)
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

COLOR_MODE_GRAYSCALE

private static final int COLOR_MODE_GRAYSCALE
Field Value:
1

COLOR_MODE_INDEXED

private static final int COLOR_MODE_INDEXED
Field Value:
2

COLOR_MODE_RGB_TRUECOLOR

private static final int COLOR_MODE_RGB_TRUECOLOR
Field Value:
3

COMPRESSION_NONE

private static final short COMPRESSION_NONE
Field Value:
0

COMPRESSION_PACKBITS

private static final short COMPRESSION_PACKBITS
Field Value:
1

MAGIC_8BPS

private static final int MAGIC_8BPS
Field Value:
943870035

channels

private int channels

colorMode

private int colorMode

compression

private short compression

depth

private int depth

gray8Image

private Gray8Image gray8Image

height

private int height

in

private DataInput in

magic

private int magic

palette

private Palette palette

paletted8Image

private Paletted8Image paletted8Image

rgb24Image

private RGB24Image rgb24Image

width

private int width

Method Details

allocate

private void allocate()

getColorTypeName

private static String getColorTypeName(int colorMode)

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

load

private void load()
            throws InvalidFileStructureException,
                   IOException,
                   UnsupportedTypeException,
                   WrongFileFormatException
Attempts to load an Image from argument stream in (which could, as an example, be a RandomAccessFile instance, it implements the DataInput interface). Checks a magic byte sequence and then reads all chunks as they appear in the IFF file. Will return the resulting image or null if no image body chunk was encountered before end-of-stream. Will throw an exception if the file is corrupt, information is missing or there were reading errors.

loadHeader

private void loadHeader()
            throws IOException,
                   WrongFileFormatException
Reads the PSD header to private members of this class instance.

loadImageData

private void loadImageData()
            throws InvalidFileStructureException,
                   IOException

loadPackbitsCompressedData

private void loadPackbitsCompressedData(byte[] data,
                                        int offset,
                                        int num)
            throws InvalidFileStructureException,
                   IOException

process

public void process()
            throws OperationFailedException
Overrides:
process in interface Operation