Package net.sourceforge.jiu.codecs
Class PSDCodec
java.lang.Object
net.sourceforge.jiu.ops.Operation
net.sourceforge.jiu.codecs.ImageCodec
net.sourceforge.jiu.codecs.PSDCodec
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
FieldsModifier and TypeFieldDescriptionprivate intprivate static final intprivate static final intprivate static final intprivate intprivate shortprivate static final shortprivate static final shortprivate intprivate Gray8Imageprivate intprivate DataInputprivate intprivate static final intprivate Paletteprivate Paletted8Imageprivate RGB24Imageprivate int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidallocate()private static StringgetColorTypeName(int colorMode) 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 voidload()Attempts to load an Image from argument streamin(which could, as an example, be aRandomAccessFileinstance, it implements theDataInputinterface).private voidReads the PSD header to private members of this class instance.private voidprivate voidloadPackbitsCompressedData(byte[] data, int offset, int num) 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, getFileExtensions, 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_8BPS
private static final int MAGIC_8BPS- See Also:
-
COLOR_MODE_GRAYSCALE
private static final int COLOR_MODE_GRAYSCALE- See Also:
-
COLOR_MODE_INDEXED
private static final int COLOR_MODE_INDEXED- See Also:
-
COLOR_MODE_RGB_TRUECOLOR
private static final int COLOR_MODE_RGB_TRUECOLOR- See Also:
-
COMPRESSION_NONE
private static final short COMPRESSION_NONE- See Also:
-
COMPRESSION_PACKBITS
private static final short COMPRESSION_PACKBITS- See Also:
-
magic
private int magic -
channels
private int channels -
height
private int height -
width
private int width -
depth
private int depth -
colorMode
private int colorMode -
compression
private short compression -
in
-
gray8Image
-
palette
-
paletted8Image
-
rgb24Image
-
-
Constructor Details
-
PSDCodec
public PSDCodec()
-
-
Method Details
-
allocate
private void allocate() -
getColorTypeName
-
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
-
load
private void load() throws InvalidFileStructureException, IOException, UnsupportedTypeException, WrongFileFormatExceptionAttempts to load an Image from argument streamin(which could, as an example, be aRandomAccessFileinstance, it implements theDataInputinterface). 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
Reads the PSD header to private members of this class instance.- Throws:
IOException- if there were reading errorsWrongFileFormatException
-
loadPackbitsCompressedData
private void loadPackbitsCompressedData(byte[] data, int offset, int num) throws InvalidFileStructureException, IOException -
loadImageData
-
process
Description 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:
WrongParameterException- if at least one of the input parameters was not initialized appropriately (values out of the valid interval, etc.)MissingParameterException- if any mandatory parameter was not given to the operationOperationFailedException
-