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 void
clear()
Calling this will release all cached information.java.awt.image.BufferedImage
getRGBImage()
Returns an image of the JPeg, or null if JPegs are not supported.void
write2OutputStream(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 quality level which is used to compress the image- 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.IOException
Returns 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:
getRGBImage
in classPDXObjectImage
- Returns:
- A Jpeg image.
- Throws:
java.io.IOException
-
write2OutputStream
public void write2OutputStream(java.io.OutputStream out) throws java.io.IOException
This writes the JPeg to out. Writes the Image to out.- Specified by:
write2OutputStream
in classPDXObjectImage
- Parameters:
out
- the OutputStream that the Image is written to.- Throws:
java.io.IOException
- when somethings wrong with out
-
-