Class ImageWriterBase

java.lang.Object
javax.imageio.ImageWriter
com.twelvemonkeys.imageio.ImageWriterBase
All Implemented Interfaces:
ImageTranscoder

public abstract class ImageWriterBase extends ImageWriter
Abstract base class for image writers.
Version:
$Id: ImageWriterBase.java,v 1.0 Sep 24, 2007 12:22:28 AM haraldk Exp$
Author:
Harald Kuhr, last modified by $Author: haraldk$
  • Field Details

  • Constructor Details

    • ImageWriterBase

      protected ImageWriterBase(ImageWriterSpi provider)
      Constructs an ImageWriter and sets its originatingProvider instance variable to the supplied value.

      Subclasses that make use of extensions should provide a constructor with signature (ImageWriterSpi, Object) in order to retrieve the extension object. If the extension object is unsuitable, an IllegalArgumentException should be thrown.

      Parameters:
      provider - the ImageWriterSpi that is constructing this object, or null.
  • Method Details

    • getFormatName

      public String getFormatName() throws IOException
      Throws:
      IOException
    • setOutput

      public void setOutput(Object output)
      Overrides:
      setOutput in class ImageWriter
    • assertOutput

      protected void assertOutput()
      Makes sure output is set.
      Throws:
      IllegalStateException - if getOutput() == null.
    • dispose

      public void dispose()
      Overrides:
      dispose in class ImageWriter
    • reset

      public void reset()
      Overrides:
      reset in class ImageWriter
    • resetMembers

      protected void resetMembers()
    • getDefaultStreamMetadata

      public IIOMetadata getDefaultStreamMetadata(ImageWriteParam param)
      Returns null
      Specified by:
      getDefaultStreamMetadata in class ImageWriter
      Parameters:
      param - ignored.
      Returns:
      null.
    • convertStreamMetadata

      public IIOMetadata convertStreamMetadata(IIOMetadata inData, ImageWriteParam param)
      Returns null
      Specified by:
      convertStreamMetadata in interface ImageTranscoder
      Specified by:
      convertStreamMetadata in class ImageWriter
      Parameters:
      inData - ignored.
      param - ignored.
      Returns:
      null.
    • getSourceRegion

      protected static Rectangle getSourceRegion(ImageWriteParam pParam, int pWidth, int pHeight)
    • fakeAOI

      protected static BufferedImage fakeAOI(BufferedImage pImage, ImageWriteParam pParam)
      Utility method for getting the area of interest (AOI) of an image. The AOI is defined by the IIOParam.setSourceRegion(java.awt.Rectangle) method.

      Note: If it is possible for the writer to write the AOI directly, such a method should be used instead, for efficiency.

      Parameters:
      pImage - the image to get AOI from
      pParam - the param optionally specifying the AOI
      Returns:
      a BufferedImage containing the area of interest (source region), or the original image, if no source region was set, or pParam was null
    • fakeSubsampling

      protected static Image fakeSubsampling(Image pImage, ImageWriteParam pParam)
      Utility method for getting the subsampled image. The subsampling is defined by the IIOParam.setSourceSubsampling(int, int, int, int) method.

      NOTE: This method does not take the subsampling offsets into consideration.

      Note: If it is possible for the writer to subsample directly, such a method should be used instead, for efficiency.

      Parameters:
      pImage - the image to subsample
      pParam - the param optionally specifying subsampling
      Returns:
      an Image containing the subsampled image, or the original image, if no subsampling was specified, or pParam was null