Image Class Documentation
class Image : ElementNamespace:datalogics_interface
- 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(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, int width, int height, 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
Image change_resolution(int dpi)Parameters
dpi: int- the new resolution
Returns:
Imagenewimage - 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(ElementCloneFlags flags)Parameters
flags: ElementCloneFlags
Returns:
std::unique_ptr< Element >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:
std::unique_ptr< Image >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
int get_bits_per_component()Returns:
intThe 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
Rect get_bounding_box()Returns:
RectThe 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.
get_clip
std::unique_ptr< Clip > get_clip()Returns:
std::unique_ptr< Clip >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
CompressionCode get_compression()Returns:
CompressionCodeA 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:
std::vector< unsigned char >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
bool get_did_warnings_occur_during_import()Returns:
booltrue 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
ElementType get_element_type()Returns:
ElementTypeReturns the runtime type of this element.
get_graphic_state
GraphicState get_graphic_state()Returns:
GraphicStateThe GraphicState associated with this image element.
The graphic state of the current element.
get_height
int get_height()Returns:
intThe height of the image in pixels.
The height of the image in pixels.
get_intent
std::string get_intent()Returns:
std::stringThe rendering intent name as a string.
The color rendering intent for the image.
get_is_image_mask
bool get_is_image_mask()Returns:
booltrue if the image is an image mask, false otherwise.
Indicates whether this image is an image mask.
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:
std::vector< ImageData >A list of ImageData chunks containing the decompressed image data.
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 facilitates retrieving the data in .NET and Java which have 2GB limits on object sizes.
get_matrix
Matrix get_matrix()Returns:
MatrixThe current transformation matrix applied to this element.
The transformation matrix for the element.
get_number_components
int get_number_components()Returns:
intThe 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:
std::unique_ptr< Image >image - an image, the soft mask
Gets, for this image, the soft mask (also an image).
get_width
int get_width()Returns:
intThe width of the image in pixels.
The width of the image in pixels.
get_xmp_metadata
std::string get_xmp_metadata()Returns:
std::stringReturns XMP metadata from the image's stream dictionary, or empty string if none.
operator=
Parameters
: Image &&
Returns:
Image &rotate
void rotate(double theta)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
void save(const std::string & filename, ImageType type)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
void save(const std::string & filename, ImageType type, const ImageSaveParams & params)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
void scale(double sx, double sy)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
void set_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
void set_compression(CompressionCode code)Parameters
code: CompressionCodeThe new new compression scheme to be applied.
Returns:
voidSet a Compression scheme for the image data.
To apply a G3 or G4 filter, the image must be bi-color (black and white) and 1 bit per pixel.
set_graphic_state
void set_graphic_state(GraphicState gs)Parameters
gs: GraphicState- the new/updated Graphic State for the element.
Returns:
voidSet the Graphic State of the current element.
set_intent
void set_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
void set_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
void set_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
void translate(double tx, double ty)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.