Class AddImage

java.lang.Object
org.jpedal.manipulator.AddImage
All Implemented Interfaces:
org.jpedal.manipulator.Manipulation

public class AddImage extends Object implements org.jpedal.manipulator.Manipulation
Adds an image to a document.
See Also:
  • Constructor Details

    • AddImage

      public AddImage(PdfManipulator pdfManipulator, PageRanges pages, BufferedImage image, float[] rect)
      Adds an image onto the specified pages.
      Parameters:
      pdfManipulator - the PdfManipulator object for the currently loaded document
      pages - the pages to add the image to. You may specify null for all pages.
      image - the image to add
      rect - a rectangle specifying the origin and dimensions of the image
    • AddImage

      public AddImage(PdfManipulator pdfManipulator, PageRanges pages, byte[] image, int width, int height, AddImage.ColorSpace colorSpace, float[] rect)
      Adds an image onto the specified pages.
      Parameters:
      pdfManipulator - the PdfManipulator object for the currently loaded document
      pages - the pages to add the image to. You may specify null for all pages.
      image - the image to add
      width - the width of the image to add
      height - the height of the image to add
      colorSpace - the color space that the byte array of pixels belongs to
      rect - a rectangle specifying the origin and dimensions of the image
  • Method Details

    • createXObject

      public static org.jpedal.io.writer.PdfDict createXObject(PdfManipulator pdfManipulator, org.jpedal.io.writer.PdfFile info, byte[] imageBytes, int width, int height, AddImage.ColorSpace colorSpace)
      Create an XObject dictionary for an image.
      Parameters:
      pdfManipulator - the PdfManipulator object for the currently loaded document
      info - the currently loaded document
      imageBytes - the colour bytes for the image
      width - the image width
      height - the image height
      colorSpace - the image colour space
      Returns:
      an XObject dictionary of the image
    • getImageBytes

      public static org.jpedal.utils.Pair<byte[],byte[]> getImageBytes(PdfManipulator pdfManipulator, BufferedImage image)
      Grab the pixels from a BufferedImage and put then into two byte arrays, one for pixels, one for alphas.

      This method does not support taking a subimage as input!

      Parameters:
      pdfManipulator - the PdfManipulator object for the currently loaded document
      image - the image to turn into bytes
      Returns:
      a pair containing the pixel and alpha byte arrays respectively
    • getPDFColorSpace

      public static AddImage.ColorSpace getPDFColorSpace(BufferedImage image)
      Determine what PDF colorspace a BufferedImage belongs in.

      Currently Java only supports RGB and Gray.

      Parameters:
      image - the image to check
      Returns:
      the PDF colorspace