Class DecodeOptions

java.lang.Object
org.apache.pdfbox.filter.DecodeOptions
Direct Known Subclasses:
DecodeOptions.FinalDecodeOptions

public class DecodeOptions extends Object
Options that may be passed to a Filter to request special handling when decoding the stream. Filters may not honor some or all of the specified options, and so callers should check the honored flag if further processing relies on the options being used.
  • Field Details

    • DEFAULT

      public static final DecodeOptions DEFAULT
      Default decode options. The honored flag for this instance is always true, as it represents the default behavior.
    • sourceRegion

      private Rectangle sourceRegion
    • subsamplingX

      private int subsamplingX
    • subsamplingY

      private int subsamplingY
    • subsamplingOffsetX

      private int subsamplingOffsetX
    • subsamplingOffsetY

      private int subsamplingOffsetY
    • filterSubsampled

      private boolean filterSubsampled
  • Constructor Details

    • DecodeOptions

      public DecodeOptions()
      Constructs an empty DecodeOptions instance
    • DecodeOptions

      public DecodeOptions(Rectangle sourceRegion)
      Constructs an instance specifying the region of the image that should be decoded. The actual region will be clipped to the dimensions of the image.
      Parameters:
      sourceRegion - Region of the source image that should be decoded
    • DecodeOptions

      public DecodeOptions(int x, int y, int width, int height)
      Constructs an instance specifying the region of the image that should be decoded. The actual region will be clipped to the dimensions of the image.
      Parameters:
      x - x-coordinate of the top-left corner of the region to be decoded
      y - y-coordinate of the top-left corner of the region to be decoded
      width - Width of the region to be decoded
      height - Height of the region to be decoded
    • DecodeOptions

      public DecodeOptions(int subsampling)
      Constructs an instance specifying the image should be decoded using subsampling. The subsampling will be the same for the X and Y axes.
      Parameters:
      subsampling - The number of rows and columns to advance in the source for each pixel in the decoded image.
  • Method Details

    • getSourceRegion

      public Rectangle getSourceRegion()
      When decoding an image, the part of the image that should be decoded, or null if the entire image is needed.
      Returns:
      The source region to decode, or null if the entire image should be decoded
    • setSourceRegion

      public void setSourceRegion(Rectangle sourceRegion)
      Sets the region of the source image that should be decoded. The region will be clipped to the dimensions of the source image. Setting this value to null will result in the entire image being decoded.
      Parameters:
      sourceRegion - The source region to decode, or null if the entire image should be decoded.
    • getSubsamplingX

      public int getSubsamplingX()
      When decoding an image, the number of columns to advance in the source for every pixel decoded.
      Returns:
      The x-axis subsampling value
    • setSubsamplingX

      public void setSubsamplingX(int ssX)
      Sets the number of columns to advance in the source for every pixel decoded
      Parameters:
      ssX - The x-axis subsampling value
    • getSubsamplingY

      public int getSubsamplingY()
      When decoding an image, the number of rows to advance in the source for every pixel decoded.
      Returns:
      The y-axis subsampling value
    • setSubsamplingY

      public void setSubsamplingY(int ssY)
      Sets the number of rows to advance in the source for every pixel decoded
      Parameters:
      ssY - The y-axis subsampling value
    • getSubsamplingOffsetX

      public int getSubsamplingOffsetX()
      When decoding an image, the horizontal offset for subsampling
      Returns:
      The x-axis subsampling offset
    • setSubsamplingOffsetX

      public void setSubsamplingOffsetX(int ssOffsetX)
      Sets the horizontal subsampling offset for decoding images
      Parameters:
      ssOffsetX - The x-axis subsampling offset
    • getSubsamplingOffsetY

      public int getSubsamplingOffsetY()
      When decoding an image, the vertical offset for subsampling
      Returns:
      The y-axis subsampling offset
    • setSubsamplingOffsetY

      public void setSubsamplingOffsetY(int ssOffsetY)
      Sets the vertical subsampling offset for decoding images
      Parameters:
      ssOffsetY - The y-axis subsampling offset
    • isFilterSubsampled

      public boolean isFilterSubsampled()
      Flag used by the filter to specify if it performed subsampling. Some filters may be unable or unwilling to apply subsampling, and so the caller must check this flag after decoding.
      Returns:
      True if the filter applied the options specified by this instance, false otherwise.
    • setFilterSubsampled

      void setFilterSubsampled(boolean filterSubsampled)
      Used internally by filters to signal they have applied subsampling as requested by this options instance.
      Parameters:
      filterSubsampled - Value specifying if the filter could meet the requested options. Usually a filter will only call this with the value true, as the default value for the flag is false.