Class PDFImageColorModel

java.lang.Object
java.awt.image.ColorModel
com.inductiveautomation.rm.pdf.reader.PDFImageColorModel
All Implemented Interfaces:
Transparency

public class PDFImageColorModel extends ColorModel
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.

  • 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

      public void setSoftMask(PDFImageColorModel.SoftMask m)
      Specify softmask (alpha) information for this image
    • getNumSourceComponents

      public int getNumSourceComponents()
      Returns the number of color components present in the input pixels
    • coerceData

      public ColorModel coerceData(WritableRaster r, boolean premultipliedAlpha)
      CoerceData.
      Overrides:
      coerceData in class ColorModel
    • isCompatibleRaster

      public boolean isCompatibleRaster(Raster r)
      Not sure.
      Overrides:
      isCompatibleRaster in class ColorModel
    • 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 class ColorModel
    • getRed

      public int getRed(int pixel)
      Specified by:
      getRed in class ColorModel
    • getGreen

      public int getGreen(int pixel)
      Specified by:
      getGreen in class ColorModel
    • getBlue

      public int getBlue(int pixel)
      Specified by:
      getBlue in class ColorModel
    • getAlpha

      public int getAlpha(int pixel)
      Specified by:
      getAlpha in class ColorModel
    • getRGB

      public int getRGB(Object inData)
      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 class ColorModel