Class SampledImageReader

java.lang.Object
org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader

final class SampledImageReader extends Object
Reads a sampled image from a PDF file.
  • Field Details

    • LOG

      private static final org.apache.commons.logging.Log LOG
  • Constructor Details

    • SampledImageReader

      private SampledImageReader()
  • Method Details

    • getStencilImage

      public static BufferedImage getStencilImage(PDImage pdImage, Paint paint) throws IOException
      Returns an ARGB image filled with the given paint and using the given image as a mask.
      Parameters:
      paint - the paint to fill the visible portions of the image with
      Returns:
      a masked image filled with the given paint
      Throws:
      IOException - if the image cannot be read
      IllegalStateException - if the image is not a stencil.
    • getRGBImage

      public static BufferedImage getRGBImage(PDImage pdImage, COSArray colorKey) throws IOException
      Returns the content of the given image as an AWT buffered image with an RGB color space. If a color key mask is provided then an ARGB image is returned instead. This method never returns null.
      Parameters:
      pdImage - the image to read
      colorKey - an optional color key mask
      Returns:
      content of this image as an RGB buffered image
      Throws:
      IOException - if the image cannot be read
    • clipRegion

      private static Rectangle clipRegion(PDImage pdImage, Rectangle region)
    • getRGBImage

      public static BufferedImage getRGBImage(PDImage pdImage, Rectangle region, int subsampling, COSArray colorKey) throws IOException
      Returns the content of the given image as an AWT buffered image with an RGB color space. If a color key mask is provided then an ARGB image is returned instead. This method never returns null.
      Parameters:
      pdImage - the image to read
      region - The region of the source image to get, or null if the entire image is needed. The actual region will be clipped to the dimensions of the source image.
      subsampling - The amount of rows and columns to advance for every output pixel, a value of 1 meaning every pixel will be read. It must not be larger than the image width or height.
      colorKey - an optional color key mask
      Returns:
      content of this image as an (A)RGB buffered image
      Throws:
      IOException - if the image cannot be read
    • getRawRaster

      public static WritableRaster getRawRaster(PDImage pdImage) throws IOException
      Extract the raw unconverted raster of the given image
      Parameters:
      pdImage - The image to get the raw raster data from
      Returns:
      the raw raster of this image
      Throws:
      IOException
    • readRasterFromAny

      private static void readRasterFromAny(PDImage pdImage, WritableRaster raster) throws IOException
      Throws:
      IOException
    • from1Bit

      private static BufferedImage from1Bit(PDImage pdImage, Rectangle clipped, int subsampling, int width, int height) throws IOException
      Throws:
      IOException
    • from8bit

      private static BufferedImage from8bit(PDImage pdImage, WritableRaster raster, Rectangle clipped, int subsampling, int width, int height) throws IOException
      Throws:
      IOException
    • fromAny

      private static BufferedImage fromAny(PDImage pdImage, WritableRaster raster, COSArray colorKey, Rectangle clipped, int subsampling, int width, int height) throws IOException
      Throws:
      IOException
    • applyColorKeyMask

      private static BufferedImage applyColorKeyMask(BufferedImage image, BufferedImage mask)
    • getDecodeArray

      private static float[] getDecodeArray(PDImage pdImage) throws IOException
      Throws:
      IOException