Class BitmapImagePixels

java.lang.Object
com.itextpdf.pdfoptimizer.handlers.util.BitmapImagePixels

public class BitmapImagePixels extends Object
Class allows to process pixels of the bitmap image stored as byte array according to PDF specification.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BitmapImagePixels(int width, int height, int bitsPerComponent, int numberOfComponents)
    Creates a representation of empty image.
    BitmapImagePixels(int width, int height, int bitsPerComponent, int numberOfComponents, byte[] data)
    Creates a representation of an image presented as bytes array.
    BitmapImagePixels(com.itextpdf.kernel.pdf.xobject.PdfImageXObject image)
    Creates a representation of an image presented as PdfImageXObject.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Getter for bits per component parameter of the image.
    byte[]
    Getter for byte representation of the image.
    int
    Getter for a height of the image.
    int
    Gets the maximum value for the component.
    int
    Getter for number of components parameter of the image.
    double[]
    getPixel(int x, int y)
    Gets pixel of the image.
    long[]
    getPixelAsLongs(int x, int y)
    Gets pixel of the image presented as long values.
    int
    Getter for a width of the image.
    void
    setPixel(int x, int y, double[] value)
    Updates a pixel of the image.
    void
    setPixel(int x, int y, long[] value)
    Updates a pixel of the image.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BitmapImagePixels

      public BitmapImagePixels (int width, int height, int bitsPerComponent, int numberOfComponents)
      Creates a representation of empty image.
      Parameters:
      width - is a width of the image
      height - is a height of the image
      bitsPerComponent - is an amount of bits representing each color component of a pixel
      numberOfComponents - is a number of components representing a pixel
    • BitmapImagePixels

      public BitmapImagePixels (com.itextpdf.kernel.pdf.xobject.PdfImageXObject image)
      Creates a representation of an image presented as PdfImageXObject.
      Parameters:
      image - is an image as PdfImageXObject
    • BitmapImagePixels

      public BitmapImagePixels (int width, int height, int bitsPerComponent, int numberOfComponents, byte[] data)
      Creates a representation of an image presented as bytes array.
      Parameters:
      width - is a width of the image
      height - is a height of the image
      bitsPerComponent - is an amount of bits representing each color component of a pixel
      numberOfComponents - is a number of components representing a pixel
      data - is an image data
  • Method Details

    • getPixel

      public double[] getPixel (int x, int y)
      Gets pixel of the image.
      Parameters:
      x - is an x-coordinate of a pixel to update
      y - is a y-coordinate of a pixel to update
      Returns:
      an array representing pixel color according to used color space
    • getPixelAsLongs

      public long[] getPixelAsLongs (int x, int y)
      Gets pixel of the image presented as long values.
      Parameters:
      x - is an x-coordinate of a pixel to update
      y - is a y-coordinate of a pixel to update
      Returns:
      an array representing pixel color according to used color space
    • setPixel

      public void setPixel (int x, int y, double[] value)
      Updates a pixel of the image.
      Parameters:
      x - is an x-coordinate of a pixel to update
      y - is a y-coordinate of a pixel to update
      value - is a pixel color. Pixel should be presented as double array according to used color space. Each value should be in range [0., 1.] (otherwise negative value will be replaced with 0. and large numbers are replaced with 1.)
    • setPixel

      public void setPixel (int x, int y, long[] value)
      Updates a pixel of the image.
      Parameters:
      x - is an x-coordinate of a pixel to update
      y - is a y-coordinate of a pixel to update
      value - is a pixel color. Pixel should be presented as long array according to used color space. Each value should be in range [0, 2 ^ bitsPerComponent - 1] (otherwise negative value will be replaced with 0. and large numbers are replaced with maximum allowed value.)
    • getWidth

      public int getWidth()
      Getter for a width of the image.
      Returns:
      width of the image
    • getHeight

      public int getHeight()
      Getter for a height of the image.
      Returns:
      height of the image
    • getBitsPerComponent

      public int getBitsPerComponent()
      Getter for bits per component parameter of the image.
      Returns:
      bits per component parameter of the image
    • getNumberOfComponents

      public int getNumberOfComponents()
      Getter for number of components parameter of the image.
      Returns:
      number of components of the image
    • getData

      public byte[] getData()
      Getter for byte representation of the image.
      Returns:
      image data as byte array
    • getMaxComponentValue

      public int getMaxComponentValue()
      Gets the maximum value for the component.
      Returns:
      maximum value of the component