Image Class Documentation
classImage : ElementNamespace:datalogics_interface
- Inherits from:
Element
Detailed Description
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(const std::string &file_name)Parameters
file_name: const std::string &the 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(const std::string &file_name, class Document &document)Parameters
file_name: const std::string &the filename of the image file.
document: class Document &
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(const std::vector< unsigned char > &buffer, intwidth, intheight, const ColorSpace &color_space)Parameters
buffer: const std::vector< unsigned char > &the filename of the image file.
width: intheight: intcolor_space: const ColorSpace &
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(Image &&)Parameters
: Image &&
Image
Image(std::istream &input_stream)Parameters
input_stream: std::istream &
Create an Image from an input stream containing image data. Supports TIFF, JPEG, BMP, PNG, GIF formats. The stream only needs to remain valid for the duration of construction.
Image
Image(std::istream &input_stream, Document &document)Parameters
input_stream: std::istream &document: Document &
Create an Image from an input stream, optimized for a specific document.
~Image
~Image()Member Function Documentation
change_resolution
Imagechange_resolution(intdpi)Parameters
dpi: int- the 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
std::unique_ptr< Element >clone(ElementCloneFlagsflags)Parameters
flags: ElementCloneFlags
Returns:
The copied element.Makes a copy of the element.
Make a copy of an element to obtain a new element that has a distinct set of attributes.
Note: TextRun objects may not be cloned.
clone
std::unique_ptr< Image >clone()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.
get_bits_per_component
intget_bits_per_component()Returns:
The number of bits per component (e.g. 1, 2, 4, 8, or 16).The number of bits per component in the image.
get_bounding_box
Rectget_bounding_box()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 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.
get_clip
std::unique_ptr< Clip >get_clip()Returns:
The current Clip for this Element, or NULL if no clip is set.Gets the current Clip for an Element.
get_color_space
std::unique_ptr< ColorSpace >get_color_space()Returns:
std::unique_ptr< ColorSpace >return the ColorSpace with which this Image was created.
get_compression
CompressionCodeget_compression()Returns:
A compression code which represents the filter used in the image data.The compression filter applied to the image data.
get_data
std::vector< unsigned char >get_data()Returns:
A byte array containing the raw image data.The actual bytes that make up the image, exactly as they appear in the image data.
get_did_warnings_occur_during_import
boolget_did_warnings_occur_during_import()Returns:
true if warnings were generated during the image import process, false otherwise.Indicates whether warnings occurred during import of the raster image file.
get_element_type
ElementTypeget_element_type()Returns:
ElementTypeReturns the runtime type of this element.
get_graphic_state
GraphicStateget_graphic_state()Returns:
The GraphicState associated with this image element.The graphic state of the current element.
get_height
intget_height()Returns:
The height of the image in pixels.The height of the image in pixels.
get_intent
std::stringget_intent()Returns:
The rendering intent name as a string.The color rendering intent for the image.
get_is_image_mask
boolget_is_image_mask()Returns:
true if the image is an image mask, false otherwise.An image mask is a 1-bit-per-pixel image used to select painting in the current color rather than displaying image samples.
get_large_data
std::vector< ImageData >get_large_data()Returns:
A list of ImageData chunks containing the decompressed image data.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 facilitates retrieving the data in .NET and Java which have 2GB limits on object sizes.
get_matrix
Matrixget_matrix()Returns:
The current transformation matrix applied to this element.The transformation matrix for the element.
get_number_components
intget_number_components()Returns:
The number of color components (e.g. 1 for grayscale, 3 for RGB, 4 for CMYK).The number of color components in the image.
get_soft_mask
std::unique_ptr< Image >get_soft_mask()Returns:
image - an image, the soft maskGets, for this image, the soft mask (also an image).
get_width
intget_width()Returns:
The width of the image in pixels.The width of the image in pixels.
get_xmp_metadata
std::stringget_xmp_metadata()Returns:
std::stringReturns XMP metadata from the image's stream dictionary, or empty string if none.
operator=
Parameters
: Image &&
Returns:
Image &rotate
voidrotate(doubletheta)Parameters
theta: doubleThe rotation angle in degrees.
Returns:
voidRotate an element by theta degrees counterclockwise using the matrix [ cos T sin T -sin T cos T 0 0 ].
save
voidsave(const std::string &filename, ImageTypetype)Parameters
filename: const std::string &- The physical image file which will be created.
type: ImageType- The ImageType used for saving the image.
Returns:
voidSave an image into a particular file format with the given parameters for saving.
save
voidsave(const std::string &filename, ImageTypetype, const ImageSaveParams ¶ms)Parameters
filename: const std::string &- The physical image file which will be created.
type: ImageType- The ImageType used for saving the image.
params: const ImageSaveParams &- The 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: doubleThe horizontal scale factor.
sy: doubleThe vertical scale factor.
Returns:
voidScale an element by (sx,sy) units using the matrix [ sx 0 0 sy 0 0 ].
set_clip
voidset_clip(Clip &clip)Parameters
clip: Clip &The clip to set as the current clip for this element, or NULL to remove clipping.
Returns:
voidSets the current Clip for an Element.
set_compression
voidset_compression(CompressionCodecode)Parameters
code: CompressionCodeThe new new compression scheme to be applied.
Returns:
voidTo apply a G3 or G4 filter, the image must be bi-color (black and white) and 1 bit per pixel.
set_graphic_state
voidset_graphic_state(GraphicStategs)Parameters
gs: GraphicState- the new/updated Graphic State for the element.
Returns:
voidSet the Graphic State of the current element.
set_intent
voidset_intent(const std::string &intent)Parameters
intent: const std::string &the intent name
Returns:
voidSetIntent allows to set color rendering intent for the image.
set_matrix
voidset_matrix(const Matrix &matrix)Parameters
matrix: const Matrix &The transformation matrix for the element.
Returns:
voidSet the transformation matrix for the element.
set_soft_mask
voidset_soft_mask(Image &mask)Parameters
mask: Image &- an 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: doubleThe horizontal translation distance in user space units.
ty: doubleThe vertical translation distance in user space units.
Returns:
voidTranslate an element by (tx,ty) units using the matrix [ 1 0 0 1 tx ty ].
try_as
T *try_as(typename T)Parameters
: typename T
Returns:
T *Attempt to downcast this element to a derived type. Returns a pointer to the derived type, or nullptr if the type doesn't match.
try_as
const T *try_as(typename T)Parameters
: typename T
Returns:
const T *Const overload of try_as(). Returns a const pointer, or nullptr.