Class PDPattern
java.lang.Object
org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace
org.apache.pdfbox.pdmodel.graphics.color.PDSpecialColorSpace
org.apache.pdfbox.pdmodel.graphics.color.PDPattern
- All Implemented Interfaces:
COSObjectable
A Pattern color space is either a Tiling pattern or a Shading pattern.
- Author:
- John Hewson, Ben Litchfield
-
Field Summary
Fields inherited from class org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace
array
-
Constructor Summary
ConstructorsConstructorDescriptionPDPattern
(PDResources resources) Creates a new pattern color space.PDPattern
(PDResources resources, PDColorSpace colorSpace) Creates a new uncolored tiling pattern color space. -
Method Summary
Modifier and TypeMethodDescriptionfloat[]
getDefaultDecode
(int bitsPerComponent) Returns the default decode array for this color space.Returns the initial color value for this color space.getName()
Returns the name of the color space.int
Returns the number of components in this color spacegetPattern
(PDColor color) Returns the pattern for the given color.Returns the underlying color space, if this is an uncolored tiling pattern, otherwise null.toRawImage
(WritableRaster raster) Returns the image in this colorspace or null.float[]
toRGB
(float[] value) Returns the RGB equivalent of the given color value.toRGBImage
(WritableRaster raster) Returns the (A)RGB equivalent of the given raster.toString()
Methods inherited from class org.apache.pdfbox.pdmodel.graphics.color.PDSpecialColorSpace
getCOSObject
Methods inherited from class org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace
create, create, create, toRawImage, toRGBImageAWT
-
Constructor Details
-
PDPattern
Creates a new pattern color space.- Parameters:
resources
- The current resources.
-
PDPattern
Creates a new uncolored tiling pattern color space.- Parameters:
resources
- The current resources.colorSpace
- The underlying color space.
-
-
Method Details
-
getName
Description copied from class:PDColorSpace
Returns the name of the color space.- Specified by:
getName
in classPDColorSpace
- Returns:
- the name of the color space
-
getNumberOfComponents
public int getNumberOfComponents()Description copied from class:PDColorSpace
Returns the number of components in this color space- Specified by:
getNumberOfComponents
in classPDColorSpace
- Returns:
- the number of components in this color space
-
getDefaultDecode
public float[] getDefaultDecode(int bitsPerComponent) Description copied from class:PDColorSpace
Returns the default decode array for this color space.- Specified by:
getDefaultDecode
in classPDColorSpace
- Parameters:
bitsPerComponent
- the number of bits per component.- Returns:
- the default decode array
-
getInitialColor
Description copied from class:PDColorSpace
Returns the initial color value for this color space.- Specified by:
getInitialColor
in classPDColorSpace
- Returns:
- the initial color value for this color space
-
toRGB
public float[] toRGB(float[] value) Description copied from class:PDColorSpace
Returns the RGB equivalent of the given color value.- Specified by:
toRGB
in classPDColorSpace
- Parameters:
value
- a color value with component values between 0 and 1- Returns:
- an array of R,G,B value between 0 and 255
-
toRGBImage
Description copied from class:PDColorSpace
Returns the (A)RGB equivalent of the given raster.- Specified by:
toRGBImage
in classPDColorSpace
- Parameters:
raster
- the source raster- Returns:
- an (A)RGB buffered image
- Throws:
IOException
- if the color conversion fails
-
toRawImage
Description copied from class:PDColorSpace
Returns the image in this colorspace or null. No conversion is performed. For special colorspaces like PDSeparation the image is returned in the gray colorspace. For undefined colorspaces like DeviceCMYK/DeviceRGB and DeviceGray null is returned. You can always fallback toPDColorSpace.toRGBImage(WritableRaster)
if this returns null.- Specified by:
toRawImage
in classPDColorSpace
- Parameters:
raster
- the source raster- Returns:
- an buffered image in this colorspace. Or null if it is not possible to extract that image with the original colorspace without conversion.
- Throws:
IOException
-
getPattern
Returns the pattern for the given color.- Parameters:
color
- color containing a pattern name- Returns:
- pattern for the given color
- Throws:
IOException
- if the pattern name was not found.
-
getUnderlyingColorSpace
Returns the underlying color space, if this is an uncolored tiling pattern, otherwise null. -
toString
-