Class PDJpeg
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.graphics.xobject.PDXObject
-
- org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage
-
- org.apache.pdfbox.pdmodel.graphics.xobject.PDJpeg
-
- All Implemented Interfaces:
COSObjectable
public class PDJpeg extends PDXObjectImage
An image class for JPegs.- Author:
- mathiak
-
-
Field Summary
-
Fields inherited from class org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage
SUB_TYPE
-
-
Constructor Summary
Constructors Constructor Description PDJpeg(PDStream jpeg)Standard constructor.PDJpeg(PDDocument doc, java.awt.image.BufferedImage bi)Construct from a buffered image.PDJpeg(PDDocument doc, java.awt.image.BufferedImage bi, float compressionQuality)Construct from a buffered image.PDJpeg(PDDocument doc, java.io.InputStream is)Construct from a stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Calling this will release all cached information.java.awt.image.BufferedImagegetRGBImage()Returns an image of the JPeg, or null if JPegs are not supported.voidwrite2OutputStream(java.io.OutputStream out)This writes the JPeg to out.-
Methods inherited from class org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage
applyMasks, createThumbnailXObject, getBitsPerComponent, getColorSpace, getDecode, getHeight, getImageMask, getMask, getSMaskImage, getStencilColor, getSuffix, getWidth, hasMask, imageMask, mask, setBitsPerComponent, setColorSpace, setHeight, setStencilColor, setWidth, write2file, write2file
-
Methods inherited from class org.apache.pdfbox.pdmodel.graphics.xobject.PDXObject
commonXObjectCreation, createXObject, getCOSObject, getCOSStream, getMetadata, getPDStream, getStructParent, setMetadata, setStructParent
-
-
-
-
Constructor Detail
-
PDJpeg
public PDJpeg(PDStream jpeg)
Standard constructor.- Parameters:
jpeg- The COSStream from which to extract the JPeg
-
PDJpeg
public PDJpeg(PDDocument doc, java.io.InputStream is) throws java.io.IOException
Construct from a stream.- Parameters:
doc- The document to create the image as part of.is- The stream that contains the jpeg data.- Throws:
java.io.IOException- If there is an error reading the jpeg data.
-
PDJpeg
public PDJpeg(PDDocument doc, java.awt.image.BufferedImage bi) throws java.io.IOException
Construct from a buffered image. The default compression level of 0.75 will be used.- Parameters:
doc- The document to create the image as part of.bi- The image to convert to a jpeg- Throws:
java.io.IOException- If there is an error processing the jpeg data.
-
PDJpeg
public PDJpeg(PDDocument doc, java.awt.image.BufferedImage bi, float compressionQuality) throws java.io.IOException
Construct from a buffered image.- Parameters:
doc- The document to create the image as part of.bi- The image to convert to a jpegcompressionQuality- The desired JPEG compression quality; between 0 (best compression) and 1 (best image quality). SeeImageWriteParam.setCompressionQuality(float)for more details.- Throws:
java.io.IOException- If there is an error processing the jpeg data.
-
-
Method Detail
-
getRGBImage
public java.awt.image.BufferedImage getRGBImage() throws java.io.IOExceptionReturns an image of the JPeg, or null if JPegs are not supported. (They should be. ) Returns an java.awt.Image, that can be used for display etc.- Specified by:
getRGBImagein classPDXObjectImage- Returns:
- A Jpeg image.
- Throws:
java.io.IOException
-
write2OutputStream
public void write2OutputStream(java.io.OutputStream out) throws java.io.IOExceptionThis writes the JPeg to out. Writes the Image to out.- Specified by:
write2OutputStreamin classPDXObjectImage- Parameters:
out- the OutputStream that the Image is written to.- Throws:
java.io.IOException- when somethings wrong with out
-
-