Class LosslessFactory
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory
-
public final class LosslessFactory extends java.lang.ObjectFactory for creating a PDImageXObject containing a lossless compressed image.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classLosslessFactory.PredictorEncoder
-
Field Summary
Fields Modifier and Type Field Description (package private) static booleanUSE_PREDICTOR_ENCODERInternal, only for benchmark purpose
-
Constructor Summary
Constructors Modifier Constructor Description privateLosslessFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static PDImageXObjectcreateFromGrayImage(java.awt.image.BufferedImage image, PDDocument document)static PDImageXObjectcreateFromImage(PDDocument document, java.awt.image.BufferedImage image)Creates a new lossless encoded image XObject from a BufferedImage.private static PDImageXObjectcreateFromRGBImage(java.awt.image.BufferedImage image, PDDocument document)private static booleanisGrayImage(java.awt.image.BufferedImage image)(package private) static PDImageXObjectprepareImageXObject(PDDocument document, byte[] byteArray, int width, int height, int bitsPerComponent, PDColorSpace initColorSpace)Create a PDImageXObject using the Flate filter.
-
-
-
Field Detail
-
USE_PREDICTOR_ENCODER
static final boolean USE_PREDICTOR_ENCODER
Internal, only for benchmark purpose- See Also:
- Constant Field Values
-
-
Method Detail
-
createFromImage
public static PDImageXObject createFromImage(PDDocument document, java.awt.image.BufferedImage image) throws java.io.IOException
Creates a new lossless encoded image XObject from a BufferedImage.New for advanced users from 2.0.12 on:
If you created your image with a non standard ICC colorspace, it will be preserved. (If you load images in java using ImageIO then no need to read this segment) However a new colorspace will be created for each image. So if you create a PDF with several such images, consider replacing the colorspace with a common object to save space. This is done withPDImageXObject.getColorSpace()andPDImageXObject.setColorSpace()- Parameters:
document- the document where the image will be createdimage- the BufferedImage to embed- Returns:
- a new image XObject
- Throws:
java.io.IOException- if something goes wrong
-
isGrayImage
private static boolean isGrayImage(java.awt.image.BufferedImage image)
-
createFromGrayImage
private static PDImageXObject createFromGrayImage(java.awt.image.BufferedImage image, PDDocument document) throws java.io.IOException
- Throws:
java.io.IOException
-
createFromRGBImage
private static PDImageXObject createFromRGBImage(java.awt.image.BufferedImage image, PDDocument document) throws java.io.IOException
- Throws:
java.io.IOException
-
prepareImageXObject
static PDImageXObject prepareImageXObject(PDDocument document, byte[] byteArray, int width, int height, int bitsPerComponent, PDColorSpace initColorSpace) throws java.io.IOException
Create a PDImageXObject using the Flate filter.- Parameters:
document- The document.byteArray- array with data.width- the image widthheight- the image heightbitsPerComponent- the bits per componentinitColorSpace- the color space- Returns:
- the newly created PDImageXObject with the data compressed.
- Throws:
java.io.IOException
-
-