Top Description Fields Constructors Methods
org.apache.pdfbox.pdmodel.graphics.image

pack-priv final Class SampledImageReader

extends Object
Class Inheritance
Imports
java.awt.Graphics2D, .Paint, .Point, .Rectangle, java.awt.image.BufferedImage, .DataBuffer, .DataBufferByte, .Raster, .WritableRaster, java.io.IOException, .InputStream, java.util.Arrays, javax.imageio.stream.ImageInputStream, .MemoryCacheImageInputStream, org.apache.commons.logging.Log, .LogFactory, org.apache.pdfbox.cos.COSArray, .COSNumber, org.apache.pdfbox.filter.DecodeOptions, org.apache.pdfbox.io.IOUtils, org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace, .PDDeviceGray, .PDIndexed

Reads a sampled image from a PDF file.
Author
John Hewson

Field Summary

Modifier and TypeField and Description
private static final Log

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static BufferedImage
private static Rectangle
clipRegion(PDImage pdImage, Rectangle region)

private static BufferedImage
from1Bit(PDImage pdImage, Rectangle clipped, final int subsampling, final int width, final int height)

private static BufferedImage
from8bit(PDImage pdImage, WritableRaster raster, Rectangle clipped, final int subsampling, final int width, final int height)

private static BufferedImage
fromAny(PDImage pdImage, WritableRaster raster, COSArray colorKey, Rectangle clipped, final int subsampling, final int width, final int height)

private static float[]
public static WritableRaster

Returns:

the raw raster of this image
getRawRaster
(PDImage
The image to get the raw raster data from
pdImage
)

Extract the raw unconverted raster of the given image

public static BufferedImage

Returns:

content of this image as an RGB buffered image
getRGBImage
(PDImage
the image to read
pdImage
,
COSArray
an optional color key mask
colorKey
)

Returns the content of the given image as an AWT buffered image with an RGB color space.

public static BufferedImage

Returns:

content of this image as an (A)RGB buffered image
getRGBImage
(PDImage
the image to read
pdImage
,
Rectangle
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.
region
,
int
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.
subsampling
,
COSArray
an optional color key mask
colorKey
)

Returns the content of the given image as an AWT buffered image with an RGB color space.

public static BufferedImage

Returns:

a masked image filled with the given paint
getStencilImage
(PDImage pdImage, Paint
the paint to fill the visible portions of the image with
paint
)

Returns an ARGB image filled with the given paint and using the given image as a mask.

private static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGback to summary
private static final Log LOG

Constructor Detail

SampledImageReaderback to summary
private SampledImageReader()

Method Detail

applyColorKeyMaskback to summary
private static BufferedImage applyColorKeyMask(BufferedImage image, BufferedImage mask)
clipRegionback to summary
private static Rectangle clipRegion(PDImage pdImage, Rectangle region)
from1Bitback to summary
private static BufferedImage from1Bit(PDImage pdImage, Rectangle clipped, final int subsampling, final int width, final int height) throws IOException
from8bitback to summary
private static BufferedImage from8bit(PDImage pdImage, WritableRaster raster, Rectangle clipped, final int subsampling, final int width, final int height) throws IOException
fromAnyback to summary
private static BufferedImage fromAny(PDImage pdImage, WritableRaster raster, COSArray colorKey, Rectangle clipped, final int subsampling, final int width, final int height) throws IOException
getDecodeArrayback to summary
private static float[] getDecodeArray(PDImage pdImage) throws IOException
getRawRasterback to summary
public static WritableRaster getRawRaster(PDImage pdImage) throws IOException

Extract the raw unconverted raster of the given image

Parameters
pdImage:PDImage

The image to get the raw raster data from

Returns:WritableRaster

the raw raster of this image

getRGBImageback to summary
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:PDImage

the image to read

colorKey:COSArray

an optional color key mask

Returns:BufferedImage

content of this image as an RGB buffered image

Exceptions
IOException:
if the image cannot be read
getRGBImageback to summary
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:PDImage

the image to read

region:Rectangle

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

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

an optional color key mask

Returns:BufferedImage

content of this image as an (A)RGB buffered image

Exceptions
IOException:
if the image cannot be read
getStencilImageback to summary
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:Paint

the paint to fill the visible portions of the image with

Returns:BufferedImage

a masked image filled with the given paint

Exceptions
IOException:
if the image cannot be read
IllegalStateException:
if the image is not a stencil.
readRasterFromAnyback to summary
private static void readRasterFromAny(PDImage pdImage, WritableRaster raster) throws IOException