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

      private DataInput in
    • gray8Image

      private Gray8Image gray8Image
    • palette

      private Palette palette
    • paletted8Image

      private Paletted8Image paletted8Image
    • rgb24Image

      private RGB24Image rgb24Image
  • Constructor Details

    • PSDCodec

      public PSDCodec()
  • Method Details

    • allocate

      private void allocate()
    • getColorTypeName

      private static String getColorTypeName(int colorMode)
    • getFormatName

      public String getFormatName()
      Description copied from class: ImageCodec
      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).
      Specified by:
      getFormatName in class ImageCodec
      Returns:
      name of the file format supported by this codec
    • getMimeTypes

      public String[] getMimeTypes()
      Description copied from class: ImageCodec
      Return the MIME (Multipurpose Internet Mail Extensions) type strings for this format, or null if none are available.
      Specified by:
      getMimeTypes in class ImageCodec
      Returns:
      MIME type strings or null
    • isLoadingSupported

      public boolean isLoadingSupported()
      Description copied from class: ImageCodec
      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.
      Specified by:
      isLoadingSupported in class ImageCodec
      Returns:
      if loading is supported
    • isSavingSupported

      public boolean isSavingSupported()
      Description copied from class: ImageCodec
      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.
      Specified by:
      isSavingSupported in class ImageCodec
      Returns:
      if saving is supported
    • load

      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.
      Throws:
      InvalidFileStructureException
      IOException
      UnsupportedTypeException
      WrongFileFormatException
    • loadHeader

      private void loadHeader() throws IOException, WrongFileFormatException
      Reads the PSD header to private members of this class instance.
      Throws:
      IOException - if there were reading errors
      WrongFileFormatException
    • loadPackbitsCompressedData

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

      private void loadImageData() throws InvalidFileStructureException, IOException
      Throws:
      InvalidFileStructureException
      IOException
    • process

      public void process() throws OperationFailedException
      Description copied from class: Operation
      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 class Operation
      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 operation
      OperationFailedException