Class IndexedColor

java.lang.Object
org.loboevolution.pdfview.colorspace.PDFColorSpace
org.loboevolution.pdfview.colorspace.IndexedColor

public class IndexedColor extends PDFColorSpace
A PDFColorSpace for an IndexedColor model

Author Mike Wessler

  • Field Details

    • colorComponents

      protected byte[] colorComponents
      r,g,and b components of the color table as a single array, for Java's IndexColorModel
  • Constructor Details

    • IndexedColor

      public IndexedColor(PDFColorSpace base, int cnt, PDFObject stream) throws IOException
      create a new IndexColor PDFColorSpace based on another PDFColorSpace, a count of colors, and a stream of values. Every consecutive n bytes of the stream is interpreted as a color in the base ColorSpace, where n is the number of components in that color space.
      Parameters:
      base - the color space in which the data is interpreted
      cnt - the number of colors in the table
      stream - a stream of bytes. The number of bytes must be count*n, where n is the number of components in the base colorspace.
      Throws:
      IOException - if any.
    • IndexedColor

      public IndexedColor(Color[] table) throws IOException
      create a new IndexColor PDFColorSpace based on a table of colors.
      Parameters:
      table - an array of colors
      Throws:
      IOException - if any.
  • Method Details

    • getNumComponents

      public int getNumComponents()
      get the number of components expected in the getPaint command

      get the number of components of this colorspace (1)

      Overrides:
      getNumComponents in class PDFColorSpace
      Returns:
      a Integer object.
    • getPaint

      public PDFPaint getPaint(float[] components)
      get the PDFPaint representing the color described by the given color components

      get the color represented by the index.

      Overrides:
      getPaint in class PDFColorSpace
      Parameters:
      components - the color components corresponding to the given colorspace
      Returns:
      a PDFPaint object representing the closest Color to the given components.