Class PDFImageColorModel
java.lang.Object
java.awt.image.ColorModel
com.inductiveautomation.rm.pdf.reader.PDFImageColorModel
- All Implemented Interfaces:
Transparency
The PDFImageColorModel is a subclass of PackedColorModel which can be used to display a pdf image. It maintains the
image's colorspace, and will do color conversions from the image colorspace to sRGB.
Alpha may be taken from a SoftMask image.
This goes through colorspace conversion for every single pixel, and so is blindingly slow. A subclass which handles images in device colorspaces without conversion would probably be a good idea.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
A representation of the alpha channel. -
Field Summary
Fields inherited from class java.awt.image.ColorModel
pixel_bits, transferType
Fields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT
-
Constructor Summary
ConstructorsConstructorDescriptionPDFImageColorModel
(ColorSpace space, int bits, int[] significantBits, boolean hasalpha, int transferType) -
Method Summary
Modifier and TypeMethodDescriptioncoerceData
(WritableRaster r, boolean premultipliedAlpha) CoerceData.static PDFImageColorModel
createPDFModel
(ColorSpace space, int bps, float[] decodemins, float[] decodemaxs, boolean hasalpha) static WritableRaster
createPDFRaster
(byte[] packedbytes, PDFImageColorModel.SoftMask mask, ColorSpace space, int bps, int w, int h) static WritableRaster
createPDFRaster
(byte[] packedbytes, ColorSpace space, int bps, int w, int h) int
getAlpha
(int pixel) int
getBlue
(int pixel) int
getGreen
(int pixel) int
Returns the number of color components present in the input pixelsint
getRed
(int pixel) int
getRGB
(int pixel) Implemented under duress.int
Convert an array of elements, whose size is defined by the transfertype, into sRGB+alpha.void
init
(int bps, float[] decodemins, float[] decodemaxs) boolean
Not sure.void
Specify softmask (alpha) information for this imageMethods inherited from class java.awt.image.ColorModel
createCompatibleSampleModel, createCompatibleWritableRaster, equals, finalize, getAlpha, getAlphaRaster, getBlue, getColorSpace, getComponents, getComponents, getComponentSize, getComponentSize, getDataElement, getDataElement, getDataElements, getDataElements, getDataElements, getGreen, getNormalizedComponents, getNormalizedComponents, getNumColorComponents, getNumComponents, getPixelSize, getRed, getRGBdefault, getTransferType, getTransparency, getUnnormalizedComponents, hasAlpha, hashCode, isAlphaPremultiplied, isCompatibleSampleModel, toString
-
Constructor Details
-
PDFImageColorModel
public PDFImageColorModel(ColorSpace space, int bits, int[] significantBits, boolean hasalpha, int transferType)
-
-
Method Details
-
createPDFModel
public static PDFImageColorModel createPDFModel(ColorSpace space, int bps, float[] decodemins, float[] decodemaxs, boolean hasalpha) -
createPDFRaster
public static WritableRaster createPDFRaster(byte[] packedbytes, ColorSpace space, int bps, int w, int h) -
createPDFRaster
public static WritableRaster createPDFRaster(byte[] packedbytes, PDFImageColorModel.SoftMask mask, ColorSpace space, int bps, int w, int h) -
init
public void init(int bps, float[] decodemins, float[] decodemaxs) -
setSoftMask
Specify softmask (alpha) information for this image -
getNumSourceComponents
public int getNumSourceComponents()Returns the number of color components present in the input pixels -
coerceData
CoerceData.- Overrides:
coerceData
in classColorModel
-
isCompatibleRaster
Not sure.- Overrides:
isCompatibleRaster
in classColorModel
-
getRGB
public int getRGB(int pixel) Implemented under duress. The class defines these as abstract, so we have to provide implementations of them even though they'll never get called.- Overrides:
getRGB
in classColorModel
-
getRed
public int getRed(int pixel) - Specified by:
getRed
in classColorModel
-
getGreen
public int getGreen(int pixel) - Specified by:
getGreen
in classColorModel
-
getBlue
public int getBlue(int pixel) - Specified by:
getBlue
in classColorModel
-
getAlpha
public int getAlpha(int pixel) - Specified by:
getAlpha
in classColorModel
-
getRGB
Convert an array of elements, whose size is defined by the transfertype, into sRGB+alpha. First we normalize the components and then let the saved pdf colorspace convert into sRGB. We then merge in the alpha to get a pixel.- Overrides:
getRGB
in classColorModel
-