Package org.apache.fop.pdf
Class AlphaRasterImage
- java.lang.Object
-
- org.apache.fop.pdf.AlphaRasterImage
-
-
Constructor Summary
Constructors Constructor Description AlphaRasterImage(java.lang.String k, java.awt.image.Raster alpha)
Create a alpha channel image.AlphaRasterImage(java.lang.String k, java.awt.image.RenderedImage image)
Create a alpha channel image.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getBitsPerComponent()
Get the bits per color component for this image.PDFDeviceColorSpace
getColorSpace()
Get the color space for this image.java.lang.String
getFilterHint()
Returns a hint in form of a String (Possible values from PDFFilterList) indicating which filter setup should be used to encode the object.int
getHeight()
Get the image height in pixels.PDFICCStream
getICCStream()
Get the ICC stream for this image.java.lang.String
getKey()
Key to look up XObject.java.lang.String
getMask()
Get the PDF reference for a bitmap mask.PDFFilter
getPDFFilter()
Get the PDF Filter to be applied to the image.java.lang.String
getSoftMask()
PDFReference
getSoftMaskReference()
Get the PDF reference for a soft mask.PDFColor
getTransparentColor()
Get the transparent color.int
getWidth()
Get the image width in pixels.boolean
isInverted()
boolean
isPS()
Check if this image is a PostScript image.boolean
isTransparent()
Check if this image has a transparent color transparency.boolean
multipleFiltersAllowed()
Indicates whether multiple image filters are allowed; this is implemented because Adobe Reader does not like multiple FlateDecode filters applied to an image even though that allowed by the PDF spec; this is probable due to security concerns since many PDF malware exploits, like zip bombs, make use of a chain of FlateDecode filters.void
outputContents(java.io.OutputStream out)
Writes the raw, unencoded contents of the image to a given output stream.void
populateXObjectDictionary(PDFDictionary dict)
Populates the XObject's dictionary with additional values.void
setup(PDFDocument doc)
Setup the PDF image for the current document.
-
-
-
Constructor Detail
-
AlphaRasterImage
public AlphaRasterImage(java.lang.String k, java.awt.image.Raster alpha)
Create a alpha channel image. Creates a new bitmap image with the given data.- Parameters:
k
- the key to be used to lookup the imagealpha
- the alpha channel raster
-
AlphaRasterImage
public AlphaRasterImage(java.lang.String k, java.awt.image.RenderedImage image)
Create a alpha channel image. Extracts the alpha channel from the RenderedImage and creates a new bitmap image with the given data.- Parameters:
k
- the key to be used to lookup the imageimage
- the image (must have an alpha channel)
-
-
Method Detail
-
setup
public void setup(PDFDocument doc)
Setup the PDF image for the current document. Some image formats may need to access the document (for example to add an ICC profile to the document).
-
getKey
public java.lang.String getKey()
Key to look up XObject. This should be a unique key to refer to the image.
-
getWidth
public int getWidth()
Get the image width in pixels.
-
getHeight
public int getHeight()
Get the image height in pixels.
-
getColorSpace
public PDFDeviceColorSpace getColorSpace()
Get the color space for this image. Possible results are: DeviceGray, DeviceRGB, or DeviceCMYK- Specified by:
getColorSpace
in interfacePDFImage
- Returns:
- the color space
-
getBitsPerComponent
public int getBitsPerComponent()
Get the bits per color component for this image.- Specified by:
getBitsPerComponent
in interfacePDFImage
- Returns:
- the bits per component
-
isTransparent
public boolean isTransparent()
Check if this image has a transparent color transparency. Classes such asPDFImageXObject
rely on this simple binary model of transparency (e.g. compare toTransparency
) in order to render color key masking (see PDF Spec 1.7 Chapter 8.9.6.4). Therefore only return true if image has fully transparent colors.- Specified by:
isTransparent
in interfacePDFImage
- Returns:
- true if it has at least one fully transparent color
-
getTransparentColor
public PDFColor getTransparentColor()
Get the transparent color.- Specified by:
getTransparentColor
in interfacePDFImage
- Returns:
- the transparent color for this image
-
getMask
public java.lang.String getMask()
Get the PDF reference for a bitmap mask.
-
getSoftMask
public java.lang.String getSoftMask()
- Returns:
- null (unless overridden)
-
getSoftMaskReference
public PDFReference getSoftMaskReference()
Get the PDF reference for a soft mask.- Specified by:
getSoftMaskReference
in interfacePDFImage
- Returns:
- the PDF reference for a soft mask image (or null if there's no soft mask)
-
isInverted
public boolean isInverted()
- Specified by:
isInverted
in interfacePDFImage
- Returns:
- true for CMYK images generated by Adobe Photoshop
-
outputContents
public void outputContents(java.io.OutputStream out) throws java.io.IOException
Writes the raw, unencoded contents of the image to a given output stream.- Specified by:
outputContents
in interfacePDFImage
- Parameters:
out
- OutputStream to write to- Throws:
java.io.IOException
- if there creating stream
-
populateXObjectDictionary
public void populateXObjectDictionary(PDFDictionary dict)
Populates the XObject's dictionary with additional values. The values are added to the dictionary after all the values obtained from other methods from this interface have been put into the dictionary. That allows to override certain values.- Specified by:
populateXObjectDictionary
in interfacePDFImage
- Parameters:
dict
- the dictionary to fill
-
getICCStream
public PDFICCStream getICCStream()
Get the ICC stream for this image.- Specified by:
getICCStream
in interfacePDFImage
- Returns:
- the ICC stream for this image if any
-
isPS
public boolean isPS()
Check if this image is a PostScript image.
-
getFilterHint
public java.lang.String getFilterHint()
Returns a hint in form of a String (Possible values from PDFFilterList) indicating which filter setup should be used to encode the object.- Specified by:
getFilterHint
in interfacePDFImage
- Returns:
- the filter setup hint
-
getPDFFilter
public PDFFilter getPDFFilter()
Get the PDF Filter to be applied to the image.- Specified by:
getPDFFilter
in interfacePDFImage
- Returns:
- the PDF Filter or null
-
multipleFiltersAllowed
public boolean multipleFiltersAllowed()
Indicates whether multiple image filters are allowed; this is implemented because Adobe Reader does not like multiple FlateDecode filters applied to an image even though that allowed by the PDF spec; this is probable due to security concerns since many PDF malware exploits, like zip bombs, make use of a chain of FlateDecode filters.- Specified by:
multipleFiltersAllowed
in interfacePDFImage
-
-