Image Class Documentation
classImage : ElementNamespace:com::datalogics::PDFL
- Inherits from:
Element
Detailed Description
An image resource can either be an image XObject or inline image found in a page's content stream. An Image Xobject is stored separately from the graphics content stream in a PDF, and so can be used multiple times in the document, even across pages. The image is described in the /Xobject entry in the resources dictionary on the PDF page.
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).
Referenced by
Constructor & Destructor Documentation
Image
Image(StreamFilesf, booleanignore)Parameters
sf: StreamFileignore: boolean
Image
Image(byte[]buffer, intwidth, intheight, ColorSpacecolorSpace)Parameters
buffer: byte[]contains Image's data
width: intwidth of the image
height: intheight of the image
colorSpace: ColorSpacecolorspace with wich Image object will be created
Create an image from byte array. This constructor expects that input buffer is non-padded. If buffer doesn't correspond to the expected format, it will be stripped.
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.
Image
Image(javax.imageio.stream.ImageInputStreamstream)Parameters
stream: javax.imageio.stream.ImageInputStream
Allows to create Image object from ImageInputStream.
Image
Image(StringfileName)Parameters
fileName: Stringthe filename of the image file.
Create a new Image from an existing physical file. This file can be a bitmap, gif, jpeg, png, or a tiff file. An exception will be thrown if the image file is not any of the above.
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.
Image
Image(StringfileName, Documentdocument)Parameters
fileName: Stringthe filename of the image file.
document: Documentthe document in which the image is intended to be used.
Create a new Image from an existing physical file. This file can be a bitmap, gif, jpeg, png, or a tiff file. An exception will be thrown if the image file is not any of the above.
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.
Image
Image(JavaStreamFilefile)Parameters
file: JavaStreamFile
Image
Image(JavaStreamFilefile, Documentdocument)Parameters
file: JavaStreamFiledocument: Document
Member Function Documentation
DisposeChildren
voidDisposeChildren()Returns:
void[static initializer]
static void[static initializer]()changeResolution
ImagechangeResolution(intdpi)Parameters
dpi: intthe new resolution
Returns:
newimage - the original image modified to the new resolution.Create a new image from an existing one modifying the resolution (dots per inch)
clone
Imageclone()Returns:
The copied image.Makes a copy of the image.
Make a copy of an image to obtain a new image that has a distinct set of attributes.
clone
Imageclone(java.util.EnumSet< ElementCloneFlags >cloneFlags)Parameters
cloneFlags: java.util.EnumSet< ElementCloneFlags >Flags that modify the cloning operation.
Returns:
The copied image.Makes a copy of the image.
Make a copy of an image to obtain a new image that has a distinct set of attributes.
colorConvert
Parameters
document: DocumentThe document the element belongs to.
prof: ColorProfileThe ICC ColorProfile to be applied.
intent: RenderIntentThe ICC Rendering Intent for the ColorProfile
embed: booleanIf 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.
Returns:
A new Image with the applied ICC ColorProfile.Applies the specified ICC ColorProfile to the Image
delete
synchronized voiddelete(Booleandisposing)Parameters
disposing: Boolean
Returns:
synchronized voiddelete
synchronized voiddelete()Returns:
synchronized voidfinalize
voidfinalize()Returns:
voidgetBitsPerComponent
intgetBitsPerComponent()Returns:
intThe number of bits per component in the image.
getBoundingBox
RectgetBoundingBox()Returns:
The bounding box for this element. The coordinates of the bounding box are specified in user space coordinates, relative to the element's Content. Note that user space coordinates correspond to unrotated pages; any rotation specified in the page dictionary is not taken into account.The bounding box for this element.
The bounding box is a rectangle that is guaranteed to encompass the element, but it is not guaranteed to be the smallest box that could contain the element. For example, if the element is a Path that contains an arc, the bounding box encompasses the bezier control points, and not just the curve itself.
getBufferedImage
java.awt.image.BufferedImagegetBufferedImage()Returns:
java.awt.image.BufferedImageReturn this PDF image as a Java BufferedImage.
Images in Gray or RGB color spaces are returned without conversion, while images in other spaces are first converted to RGB.
getClip
ClipgetClip()Returns:
- The current Clip for this Element.Gets the current Clip for an Element.
getColorSpace
ColorSpacegetColorSpace()Returns:
ColorSpacereturn the ColorSpace with which this Image was created.
getCompression
CompressionCodegetCompression()Returns:
A compression code which represents the filter used in the image data.getData
byte[]getData()Returns:
byte[]The actual bytes that make up the image, exactly as they appear in the image data.
getDidWarningsOccurDuringImport
booleangetDidWarningsOccurDuringImport()Returns:
booleanGets whether or not warnings occurred during import of the raster image file.
getGraphicState
GraphicStategetGraphicState()Returns:
GraphicStateGet the graphic state of the current element.
getHeight
intgetHeight()Returns:
intThe height of the image in pixels.
getIntent
StringgetIntent()Returns:
StringThe color rendering intent for the image
getIsImageMask
booleangetIsImageMask()Returns:
booleanCheck that Image is ImageMask object
getLargeData
java.util.List< ImageData >getLargeData()Returns:
java.util.List< ImageData >Gets the decompressed image data from very large images.
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.
getMatrix
MatrixgetMatrix()Returns:
MatrixThe transformation matrix for the element.
getNumberComponents
intgetNumberComponents()Returns:
intThe number of components
getSoftMask
ImagegetSoftMask()Returns:
image - an image, the soft maskGets, for this image, the soft mask (also an image).
getStream
PDFStreamgetStream()Returns:
PDFStreamThe PDFStream object or null if there is no stream associated with the image
getWidth
intgetWidth()Returns:
intThe width of the image in pixels.
internalGetColorSpaceHival
longinternalGetColorSpaceHival()Returns:
longinternalGetColorSpaceTable
byte[]internalGetColorSpaceTable()Returns:
byte[]internalGetData
voidinternalGetData(byte[]buffer)Parameters
buffer: byte[]
Returns:
voidRetrieve the image data into the specified buffer.
internalGetData
voidinternalGetData(byte[]buffer, longstride)Parameters
buffer: byte[]the buffer into which the image data is copied
stride: longthe width of each row of pixels, of 0 if same as width of image.
Returns:
voidRetrieve the image data into the specified buffer.
internalGetNumColorSpaceComps
longinternalGetNumColorSpaceComps()Returns:
longrotate
voidrotate(doubleangle)Parameters
angle: double
Returns:
voidRotate an image on (angle) degree using the matrix [cos(a), sin(a), -sin(a), cos(a), 0, 0]. For images, this rotate is done without regard to the primary scaling of the original image
save
voidsave(Stringimagefilename, ImageTypeimageType)Parameters
imagefilename: StringThe physical image file which will be created.
imageType: ImageTypeThe IMAGETYPE used for saving the image.
Returns:
voidSave an image into a particular file format with default parameters for saving.
save
voidsave(Stringimagefilename, ImageTypeimageType, ImageSaveParamssaveparams)Parameters
imagefilename: StringThe physical image file which will be created.
imageType: ImageTypeThe ImageType used for saving the image.
saveparams: ImageSaveParamsThe ImageSaveParams for saving the image.
Returns:
voidSave an image into a particular file format with the given parameters for saving.
scale
voidscale(doublesx, doublesy)Parameters
sx: doublesy: double
Returns:
voidScale an element by (sx,sy) units using the matrix [ sx 0 0 sy 0 0 ].
setClip
voidsetClip(Clipclip)Parameters
clip: ClipThe clip to set as the current clip for this element.
Returns:
voidSets the current Clip for an Element.
setCompression
voidsetCompression(CompressionCodecode)Parameters
code: CompressionCodeThe new new compression scheme to be applied.
Returns:
voidSet a Compression scheme for the image data.
setGraphicState
voidsetGraphicState(GraphicStategstate)Parameters
gstate: GraphicStatethe new/updated Graphic State for the element.
Returns:
voidSet the Graphic State of the current element.
setIntent
voidsetIntent(Stringintent)Parameters
intent: Stringthe intent name
Returns:
voidSetIntent allows to set color rendering intent for the image.
setMatrix
voidsetMatrix(Matrixmatrix)Parameters
matrix: Matrixthe transformation matrix for the element.
Returns:
voidSet the transformation matrix for the element.
setSoftMask
voidsetSoftMask(ImagesoftMask)Parameters
softMask: Imagean image, the soft mask. If set to NULL, the soft mask is removed.
Returns:
voidSets, for this image, the soft mask (also an image).
translate
voidtranslate(doubletx, doublety)Parameters
tx: doublety: double
Returns:
voidTranslate an image by (tx,ty) units using the matrix [ 1 0 0 1 tx ty ]. For images, this translation is done without regard to the scaling and rotation of the original image.
To ensure that this translation can be done, do the translation before any further rotation or scaling.