Package org.jpedal.manipulator
Class AddImage
java.lang.Object
org.jpedal.manipulator.AddImage
- All Implemented Interfaces:
org.jpedal.manipulator.Manipulation
Adds an image to a document.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresents a color space that you can write with. -
Constructor Summary
ConstructorsConstructorDescriptionAddImage(PdfManipulator pdfManipulator, PageRanges pages, byte[] image, int width, int height, AddImage.ColorSpace colorSpace, float[] rect) Adds an image onto the specified pages.AddImage(PdfManipulator pdfManipulator, PageRanges pages, BufferedImage image, float[] rect) Adds an image onto the specified pages. -
Method Summary
Modifier and TypeMethodDescriptionstatic org.jpedal.io.writer.PdfDictcreateXObject(PdfManipulator pdfManipulator, org.jpedal.io.writer.PdfFile info, byte[] imageBytes, int width, int height, AddImage.ColorSpace colorSpace) Create an XObject dictionary for an image.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.static AddImage.ColorSpacegetPDFColorSpace(BufferedImage image) Determine what PDF colorspace a BufferedImage belongs in.
-
Constructor Details
-
AddImage
Adds an image onto the specified pages.- Parameters:
pdfManipulator- the PdfManipulator object for the currently loaded documentpages- the pages to add the image to. You may specify null for all pages.image- the image to addrect- 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 documentpages- the pages to add the image to. You may specify null for all pages.image- the image to addwidth- the width of the image to addheight- the height of the image to addcolorSpace- the color space that the byte array of pixels belongs torect- 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 documentinfo- the currently loaded documentimageBytes- the colour bytes for the imagewidth- the image widthheight- the image heightcolorSpace- 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 documentimage- the image to turn into bytes- Returns:
- a pair containing the pixel and alpha byte arrays respectively
-
getPDFColorSpace
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
-