public class Image extends Element
Image size and resoultion: For images that are imported from raster image files, the design width and height are stored in the Image object's Matrix, in the A (width) and D (depth) Matrix members, when the image is imported. These are stored in PDF units.
To derive the effective resolution of an image imported from a raster image file:
Horizontal resolution: divide the Image Width by the Image's Matrix A member and multiply by 72 to scale to DPI (dots per inch).
Vertical resolution: divide the Image Height by the Image's Matrix D member and multiply by 72 to scale to DPI (dots per inch).
| Constructor and Description |
|---|
Image(byte[] buffer,
int width,
int height,
ColorSpace colorSpace)
Create an image from byte array.
|
Image(javax.imageio.stream.ImageInputStream stream)
Allows to create Image object from ImageInputStream.
|
Image(java.lang.String fileName)
Create a new Image from an existing physical file.
|
Image(java.lang.String fileName,
Document document)
Create a new Image from an existing physical file.
|
| Modifier and Type | Method and Description |
|---|---|
Image |
changeResolution(int dpi)
Create a new image from an existing one modifying the resolution (dots per inch)
|
Image |
clone()
Makes a copy of the image.
|
Image |
clone(java.util.EnumSet<ElementCloneFlags> cloneFlags)
Makes a copy of the image.
|
Image |
colorConvert(Document document,
ColorProfile prof,
RenderIntent intent,
boolean embed)
Applies the specified ICC ColorProfile to the Image
|
void |
delete() |
int |
getBitsPerComponent()
The number of bits per component in the image.
|
java.awt.image.BufferedImage |
getBufferedImage()
Return this PDF image as a Java BufferedImage.
|
ColorSpace |
getColorSpace()
return the ColorSpace with which this Image was created.
|
CompressionCode |
getCompression() |
byte[] |
getData()
The actual bytes that make up the image, exactly as they appear in the image data.
|
boolean |
getDidWarningsOccurDuringImport()
Gets whether or not warnings occurred during import of the raster image file.
|
GraphicState |
getGraphicState()
Get the graphic state of the current element.
|
int |
getHeight()
The height of the image in pixels.
|
java.lang.String |
getIntent()
The color rendering intent for the image
|
boolean |
getIsImageMask()
Check that Image is ImageMask object
|
java.util.List<ImageData> |
getLargeData()
Gets the decompressed image data from very large images.
|
int |
getNumberComponents()
The number of components
|
Image |
getSoftMask()
Gets, for this image, the soft mask (also an image).
|
PDFStream |
getStream()
The PDFStream object or null if there is no stream associated with the image
|
int |
getWidth()
The width of the image in pixels.
|
void |
rotate(double angle)
Rotate an image on (angle) degree using the matrix [cos(a), sin(a), -sin(a), cos(a), 0, 0].
|
void |
save(java.lang.String imagefilename,
ImageType imageType)
Save an image into a particular file format with default parameters for saving.
|
void |
save(java.lang.String imagefilename,
ImageType imageType,
ImageSaveParams saveparams)
Save an image into a particular file format with the given parameters for saving.
|
void |
setCompression(CompressionCode code)
Set a Compression scheme for the image data.
|
void |
setGraphicState(GraphicState gstate)
Set the Graphic State of the current element.
|
void |
setIntent(java.lang.String intent)
SetIntent allows to set color rendering intent for the image.
|
void |
setSoftMask(Image softMask)
Sets, for this image, the soft mask (also an image).
|
void |
translate(double tx,
double ty)
Translate an image by (tx,ty) units using the matrix [ 1 0 0 1 tx ty ].
|
public Image(javax.imageio.stream.ImageInputStream stream)
throws java.io.IOException
java.io.IOExceptionpublic Image(java.lang.String fileName)
NOTICE on tiff files: If the tiff file is multi-paged, then the first "page" only of the file will be converted to an Image. See ImageCollection to convert each page in a multi-page tiff file to an Image.
fileName - the filename of the image file.public Image(java.lang.String fileName,
Document document)
Specifying the document optimizes data usage for this image within that document.
NOTICE on tiff files: If the tiff file is multi-paged, then the first "page" only of the file will be converted to an Image. See ImageCollection to convert each page in a multi-page tiff file to an Image.
fileName - the filename of the image file.document - the document in which the image is intended to be used.public Image(byte[] buffer,
int width,
int height,
ColorSpace colorSpace)
For example: The bitmap data generated by Page's drawContents(DrawParams) function is 32-bit aligned. The PDF image operator expects, however, 8-bit aligned image data. To remedy this difference, we check to see if the 32-bit aligned width is different from the 8-bit aligned width. If so, we fix the image data by stripping off the padding at the end.
buffer - contains Image's datawidth - width of the imageheight - height of the imagecolorSpace - colorspace with wich Image object will be createdpublic java.awt.image.BufferedImage getBufferedImage()
public byte[] getData()
public java.util.List<ImageData> getLargeData()
NOTE: This function is only supported in 64-bit, only if enough contiguous memory is available. The data size must exceed nearly 2GB, otherwise an exception is thrown and you would use the Data member instead to access the image data. The first members of the list returned contain a close to 2GB chunk of the data, but the last member containing the remaining data will be smaller in size. This faciliates retrieving the data in .NET and Java which have 2GB limits on object sizes.
public int getWidth()
public int getHeight()
public int getBitsPerComponent()
public int getNumberComponents()
public java.lang.String getIntent()
public void setIntent(java.lang.String intent)
intent - the intent namepublic GraphicState getGraphicState()
public void setGraphicState(GraphicState gstate)
gstate - the new/updated Graphic State for the element.public Image changeResolution(int dpi)
dpi - the new resolutionpublic void translate(double tx,
double ty)
To ensure that this translation can be done, do the translation before any further rotation or scaling.
public void rotate(double angle)
public void save(java.lang.String imagefilename,
ImageType imageType,
ImageSaveParams saveparams)
imagefilename - The physical image file which will be created.imageType - The ImageType used for saving the image.saveparams - The ImageSaveParams for saving the image.public void save(java.lang.String imagefilename,
ImageType imageType)
imagefilename - The physical image file which will be created.imageType - The IMAGETYPE used for saving the image.public PDFStream getStream()
public ColorSpace getColorSpace()
public CompressionCode getCompression()
public void setCompression(CompressionCode code)
code - The new new compression scheme to be applied.public Image getSoftMask()
public void setSoftMask(Image softMask)
softMask - an image, the soft mask. If set to NULL, the soft mask is removed.public boolean getIsImageMask()
public Image clone()
Make a copy of an image to obtain a new image that has a distinct set of attributes.
public Image clone(java.util.EnumSet<ElementCloneFlags> cloneFlags)
Make a copy of an image to obtain a new image that has a distinct set of attributes.
public Image colorConvert(Document document, ColorProfile prof, RenderIntent intent, boolean embed)
document - The document the element belongs to.prof - The ICC ColorProfile to be applied.intent - The ICC Rendering Intent for the ColorProfileembed - If true, embed the color space and make the object calibrated. If it is false and the target profile is CMYK, RGB, or Gray, the colors space of the resulting object, after conversion, will be DeviceCMYK, DeviceRGB, or DeviceGray, respectively.public boolean getDidWarningsOccurDuringImport()