pub struct ImageObject {
pub image_data: Vec<u8>,
pub width: u32,
pub height: u32,
pub bits_per_component: u8,
pub color_space: Name,
pub matrix: Matrix,
pub filter: Option<Name>,
pub xobject_id: Option<ObjectId>,
pub blend_mode: Option<BlendMode>,
pub active: bool,
pub marks: Vec<ContentMark>,
pub clip_path: Option<ClipPath>,
}Expand description
An image XObject to be placed on a page.
Fields§
§image_data: Vec<u8>Raw image data (format depends on filter).
width: u32Image width in pixels.
height: u32Image height in pixels.
bits_per_component: u8Bits per color component.
color_space: NameColor space name (e.g., DeviceRGB, DeviceGray).
matrix: MatrixTransformation matrix (scales/positions the image on the page).
filter: Option<Name>Optional filter name (e.g., FlateDecode, DCTDecode).
xobject_id: Option<ObjectId>Optional pre-existing XObject ID. If set, the image is already stored
in the document and will be referenced by this ID. If None, the
caller must create the image stream and assign an ID before generating
the content stream.
blend_mode: Option<BlendMode>Blend mode for compositing.
Corresponds to FPDFPageObj_GetBlendMode / FPDFPageObj_SetBlendMode.
active: boolWhether the object is active (visible).
Corresponds to FPDFPageObj_GetIsActive / FPDFPageObj_SetIsActive.
marks: Vec<ContentMark>Content marks attached to this object (for tagged PDF / accessibility).
Each mark corresponds to a BDC…EMC pair wrapping this object in
the content stream.
Corresponds to FPDFPageObj_CountMarks / FPDFPageObj_GetMark / etc.
clip_path: Option<ClipPath>Optional clipping path attached to this object.
Corresponds to FPDFPageObj_GetClipPath / FPDFPageObj_TransformClipPath.
Implementations§
Source§impl ImageObject
impl ImageObject
Sourcepub fn from_bitmap(bitmap: &Bitmap, matrix: Matrix) -> Self
pub fn from_bitmap(bitmap: &Bitmap, matrix: Matrix) -> Self
Create an ImageObject from a rendered Bitmap.
Converts an Rgba32 (premultiplied-alpha) bitmap to RGB24, applies
FlateDecode compression, and returns an ImageObject ready for
embedding in a PDF page.
The matrix parameter controls placement on the page. A typical
value for a w×h image at page coordinates (x, y) is
Matrix::new(w as f64, 0.0, 0.0, h as f64, x, y).
§Panics
Panics if bitmap.format != BitmapFormat::Rgba32.
Sourcepub fn from_jpeg_bytes(
jpeg_data: Vec<u8>,
matrix: Matrix,
) -> Result<Self, EditError>
pub fn from_jpeg_bytes( jpeg_data: Vec<u8>, matrix: Matrix, ) -> Result<Self, EditError>
Creates an image object embedding raw JPEG bytes directly (DCTDecode filter).
No decompression or recompression occurs — the JPEG data is stored as-is with
a /Filter /DCTDecode stream entry. The JPEG SOF header is parsed to extract
the image dimensions.
Returns an error if the provided bytes are not a recognisable JPEG (missing valid SOF0 or SOF2 marker).
Corresponds to FPDFImageObj_LoadJpegFile / FPDFImageObj_LoadJpegFileInline
in PDFium’s fpdf_edit.h.
Sourcepub fn transform(&mut self, m: &Matrix)
pub fn transform(&mut self, m: &Matrix)
Applies a matrix transform by pre-multiplying into the object’s matrix.
Corresponds to FPDFPageObj_Transform.
Sourcepub fn blend_mode(&self) -> Option<BlendMode>
pub fn blend_mode(&self) -> Option<BlendMode>
Returns the blend mode for this object.
Corresponds to FPDFPageObj_GetBlendMode.
Sourcepub fn page_obj_get_blend_mode(&self) -> Option<BlendMode>
pub fn page_obj_get_blend_mode(&self) -> Option<BlendMode>
Upstream-aligned alias for blend_mode().
Corresponds to FPDFPageObj_GetBlendMode.
Sourcepub fn get_blend_mode(&self) -> Option<BlendMode>
👎Deprecated: use page_obj_get_blend_mode() — matches upstream FPDFPageObj_GetBlendMode
pub fn get_blend_mode(&self) -> Option<BlendMode>
use page_obj_get_blend_mode() — matches upstream FPDFPageObj_GetBlendMode
Non-upstream alias — use page_obj_get_blend_mode().
Corresponds to FPDFPageObj_GetBlendMode.
Sourcepub fn set_blend_mode(&mut self, mode: Option<BlendMode>)
pub fn set_blend_mode(&mut self, mode: Option<BlendMode>)
Sets the blend mode for this object.
Corresponds to FPDFPageObj_SetBlendMode.
Sourcepub fn metadata(&self) -> ImageMetadata
pub fn metadata(&self) -> ImageMetadata
Returns metadata about this image object.
Corresponds to FPDFImageObj_GetImageMetadata.
Sourcepub fn image_obj_get_image_metadata(&self) -> ImageMetadata
pub fn image_obj_get_image_metadata(&self) -> ImageMetadata
Upstream-aligned alias for metadata().
Corresponds to FPDFImageObj_GetImageMetadata.
pub fn get_image_metadata(&self) -> ImageMetadata
use image_obj_get_image_metadata() — matches upstream FPDFImageObj_GetImageMetadata
Sourcepub fn raw_data(&self) -> &[u8] ⓘ
pub fn raw_data(&self) -> &[u8] ⓘ
Returns the raw (possibly compressed) image data.
Corresponds to FPDFImageObj_GetImageDataRaw.
Sourcepub fn image_obj_get_image_data_raw(&self) -> &[u8] ⓘ
pub fn image_obj_get_image_data_raw(&self) -> &[u8] ⓘ
Upstream-aligned alias for raw_data().
Corresponds to FPDFImageObj_GetImageDataRaw.
pub fn get_image_data_raw(&self) -> &[u8] ⓘ
use image_obj_get_image_data_raw() — matches upstream FPDFImageObj_GetImageDataRaw
Sourcepub fn decoded_data(&self) -> Result<Vec<u8>, EditError>
pub fn decoded_data(&self) -> Result<Vec<u8>, EditError>
Returns the decoded (decompressed) image data.
If a filter is set (e.g. FlateDecode), the data is decompressed via
the filter pipeline. If the image is uncompressed, returns the raw
data unchanged.
Corresponds to FPDFImageObj_GetImageDataDecoded.
Sourcepub fn image_obj_get_image_data_decoded(&self) -> Result<Vec<u8>, EditError>
pub fn image_obj_get_image_data_decoded(&self) -> Result<Vec<u8>, EditError>
Upstream-aligned alias for decoded_data().
Corresponds to FPDFImageObj_GetImageDataDecoded.
pub fn get_image_data_decoded(&self) -> Result<Vec<u8>, EditError>
use image_obj_get_image_data_decoded() — matches upstream FPDFImageObj_GetImageDataDecoded
Sourcepub fn to_bitmap(&self) -> Result<Bitmap, EditError>
pub fn to_bitmap(&self) -> Result<Bitmap, EditError>
Decodes the image data and returns it as a Bitmap.
DeviceRGBimages →BitmapFormat::Rgba32(alpha = 255)DeviceGrayimages →BitmapFormat::Gray8
Returns an error for unsupported color spaces or if the decoded data is too short for the declared dimensions.
Corresponds to FPDFImageObj_GetBitmap.
Sourcepub fn image_obj_get_bitmap(&self) -> Result<Bitmap, EditError>
pub fn image_obj_get_bitmap(&self) -> Result<Bitmap, EditError>
Upstream-aligned alias for to_bitmap().
Corresponds to FPDFImageObj_GetBitmap.
Sourcepub fn get_bitmap(&self) -> Result<Bitmap, EditError>
👎Deprecated: use image_obj_get_bitmap() — matches upstream FPDFImageObj_GetBitmap
pub fn get_bitmap(&self) -> Result<Bitmap, EditError>
use image_obj_get_bitmap() — matches upstream FPDFImageObj_GetBitmap
Non-upstream alias — use image_obj_get_bitmap().
Corresponds to FPDFImageObj_GetBitmap.
Sourcepub fn matrix(&self) -> &Matrix
pub fn matrix(&self) -> &Matrix
Returns a reference to the transformation matrix.
Corresponds to FPDFPageObj_GetMatrix.
Sourcepub fn page_obj_get_matrix(&self) -> &Matrix
pub fn page_obj_get_matrix(&self) -> &Matrix
Upstream-aligned alias for matrix().
Corresponds to FPDFPageObj_GetMatrix.
pub fn get_matrix(&self) -> &Matrix
use page_obj_get_matrix() — matches upstream FPDFPageObj_GetMatrix
Sourcepub fn set_matrix(&mut self, matrix: Matrix)
pub fn set_matrix(&mut self, matrix: Matrix)
Set the transformation matrix.
Corresponds to FPDFImageObj_SetMatrix.
Sourcepub fn image_obj_set_matrix(&mut self, matrix: Matrix)
pub fn image_obj_set_matrix(&mut self, matrix: Matrix)
Upstream-aligned alias for set_matrix().
Corresponds to FPDFImageObj_SetMatrix.
Sourcepub fn bounds(&self) -> Option<Rect>
pub fn bounds(&self) -> Option<Rect>
Returns the bounding box of this image object in page coordinates.
The unit square [0,0]–[1,1] is mapped through self.matrix and the
axis-aligned bounding box of the four transformed corners is returned.
Corresponds to FPDFPageObj_GetBounds for image objects.
Sourcepub fn mark_count(&self) -> usize
pub fn mark_count(&self) -> usize
Return the number of content marks on this object.
Corresponds to FPDFPageObj_CountMarks.
Sourcepub fn page_obj_count_marks(&self) -> usize
pub fn page_obj_count_marks(&self) -> usize
Upstream-aligned alias for mark_count().
Corresponds to FPDFPageObj_CountMarks.
Sourcepub fn count_marks(&self) -> usize
👎Deprecated: use page_obj_count_marks() — matches upstream FPDFPageObj_CountMarks
pub fn count_marks(&self) -> usize
use page_obj_count_marks() — matches upstream FPDFPageObj_CountMarks
Non-upstream alias — use page_obj_count_marks().
Corresponds to FPDFPageObj_CountMarks.
Sourcepub fn mark(&self, index: usize) -> Option<&ContentMark>
pub fn mark(&self, index: usize) -> Option<&ContentMark>
Return the content mark at the given index, or None if out of range.
Corresponds to FPDFPageObj_GetMark.
Sourcepub fn page_obj_get_mark(&self, index: usize) -> Option<&ContentMark>
pub fn page_obj_get_mark(&self, index: usize) -> Option<&ContentMark>
Upstream-aligned alias for mark().
Corresponds to FPDFPageObj_GetMark.
Sourcepub fn get_mark(&self, index: usize) -> Option<&ContentMark>
👎Deprecated: use page_obj_get_mark() — matches upstream FPDFPageObj_GetMark
pub fn get_mark(&self, index: usize) -> Option<&ContentMark>
use page_obj_get_mark() — matches upstream FPDFPageObj_GetMark
Non-upstream alias — use page_obj_get_mark().
Corresponds to FPDFPageObj_GetMark.
Sourcepub fn add_mark(&mut self, name: impl Into<String>) -> &mut ContentMark
pub fn add_mark(&mut self, name: impl Into<String>) -> &mut ContentMark
Add a new content mark with the given name and return a mutable reference to it.
Corresponds to FPDFPageObj_AddMark.
Sourcepub fn remove_mark(&mut self, index: usize) -> bool
pub fn remove_mark(&mut self, index: usize) -> bool
Remove the content mark at the given index.
Returns true if the index was valid and the mark was removed, false
if out of range.
Corresponds to FPDFPageObj_RemoveMark.
Sourcepub fn marks(&self) -> &[ContentMark]
pub fn marks(&self) -> &[ContentMark]
Return a slice of all content marks on this object.
Sourcepub fn marked_content_id(&self) -> Option<i64>
pub fn marked_content_id(&self) -> Option<i64>
Return the marked content ID (/MCID) from the first mark that has one,
or None if no mark carries an MCID.
Corresponds to FPDFPageObj_GetMarkedContentID.
Sourcepub fn page_obj_get_marked_content_id(&self) -> Option<i64>
pub fn page_obj_get_marked_content_id(&self) -> Option<i64>
Upstream-aligned alias for marked_content_id().
Corresponds to FPDFPageObj_GetMarkedContentID.
Sourcepub fn get_marked_content_id(&self) -> Option<i64>
👎Deprecated: use page_obj_get_marked_content_id() — matches upstream FPDFPageObj_GetMarkedContentID
pub fn get_marked_content_id(&self) -> Option<i64>
use page_obj_get_marked_content_id() — matches upstream FPDFPageObj_GetMarkedContentID
Non-upstream alias — use page_obj_get_marked_content_id().
Corresponds to FPDFPageObj_GetMarkedContentID.
Sourcepub fn has_transparency(&self) -> bool
pub fn has_transparency(&self) -> bool
Returns true if this image object has any transparency.
An image object is considered transparent when it has a non-Normal
blend mode.
Corresponds to FPDFPageObj_HasTransparency.
Sourcepub fn is_transparent(&self) -> bool
👎Deprecated: use has_transparency() — matches upstream FPDFPageObj_HasTransparency
pub fn is_transparent(&self) -> bool
use has_transparency() — matches upstream FPDFPageObj_HasTransparency
Non-upstream convenience alias for has_transparency().
Prefer has_transparency(), which matches
the upstream FPDFPageObj_HasTransparency name exactly.
Sourcepub fn object_type(&self) -> u32
pub fn object_type(&self) -> u32
Returns the PDFium page-object-type constant for image objects: 3.
Corresponds to FPDFPageObj_GetType returning FPDF_PAGEOBJ_IMAGE.
Sourcepub fn get_object_type(&self) -> u32
👎Deprecated: use page_obj_get_type() — matches upstream FPDFPageObj_GetType
pub fn get_object_type(&self) -> u32
use page_obj_get_type() — matches upstream FPDFPageObj_GetType
Non-upstream alias — use page_obj_get_type().
The actual upstream function is FPDFPageObj_GetType; there is no
FPDFPageObj_GetObjectType.
Sourcepub fn page_obj_get_type(&self) -> u32
pub fn page_obj_get_type(&self) -> u32
Upstream-aligned alias for object_type().
Corresponds to FPDFPageObj_GetType.
pub fn get_type(&self) -> u32
use page_obj_get_type() — matches upstream FPDFPageObj_GetType
Sourcepub fn filter_count(&self) -> usize
pub fn filter_count(&self) -> usize
Returns the number of filters applied to this image’s data stream.
This implementation stores at most one filter; returns 1 when a filter
is present, 0 otherwise.
Corresponds to FPDFImageObj_GetImageFilterCount.
Sourcepub fn image_obj_get_image_filter_count(&self) -> usize
pub fn image_obj_get_image_filter_count(&self) -> usize
Upstream-aligned alias for filter_count().
Corresponds to FPDFImageObj_GetImageFilterCount.
Sourcepub fn get_image_filter_count(&self) -> usize
👎Deprecated: use image_obj_get_image_filter_count() — matches upstream FPDFImageObj_GetImageFilterCount
pub fn get_image_filter_count(&self) -> usize
use image_obj_get_image_filter_count() — matches upstream FPDFImageObj_GetImageFilterCount
Non-upstream alias — use image_obj_get_image_filter_count().
Corresponds to FPDFImageObj_GetImageFilterCount.
Sourcepub fn filter(&self, index: usize) -> Option<&str>
pub fn filter(&self, index: usize) -> Option<&str>
Returns the filter name at the given index as a &str, or None if the
index is out of range.
Only index 0 is valid; any other index returns None.
Corresponds to FPDFImageObj_GetImageFilter.
Sourcepub fn image_obj_get_image_filter(&self, index: usize) -> Option<&str>
pub fn image_obj_get_image_filter(&self, index: usize) -> Option<&str>
Upstream-aligned alias for filter().
Corresponds to FPDFImageObj_GetImageFilter.
Sourcepub fn get_image_filter(&self, index: usize) -> Option<&str>
👎Deprecated: use image_obj_get_image_filter() — matches upstream FPDFImageObj_GetImageFilter
pub fn get_image_filter(&self, index: usize) -> Option<&str>
use image_obj_get_image_filter() — matches upstream FPDFImageObj_GetImageFilter
Non-upstream alias — use image_obj_get_image_filter().
Corresponds to FPDFImageObj_GetImageFilter.
Sourcepub fn get_filter(&self, index: usize) -> Option<&str>
👎Deprecated: use image_obj_get_image_filter() — matches upstream FPDFImageObj_GetImageFilter
pub fn get_filter(&self, index: usize) -> Option<&str>
use image_obj_get_image_filter() — matches upstream FPDFImageObj_GetImageFilter
Non-upstream alias — use image_obj_get_image_filter().
Corresponds to FPDFImageObj_GetImageFilter.
Sourcepub fn pixel_size(&self) -> (u32, u32)
pub fn pixel_size(&self) -> (u32, u32)
Returns the pixel dimensions of this image object.
Returns (width, height) in pixels.
Corresponds to FPDFImageObj_GetImagePixelSize.
Sourcepub fn image_obj_get_image_pixel_size(&self) -> (u32, u32)
pub fn image_obj_get_image_pixel_size(&self) -> (u32, u32)
Upstream-aligned alias for pixel_size().
Corresponds to FPDFImageObj_GetImagePixelSize.
Sourcepub fn get_image_pixel_size(&self) -> (u32, u32)
👎Deprecated: use image_obj_get_image_pixel_size() — matches upstream FPDFImageObj_GetImagePixelSize
pub fn get_image_pixel_size(&self) -> (u32, u32)
use image_obj_get_image_pixel_size() — matches upstream FPDFImageObj_GetImagePixelSize
Non-upstream alias — use image_obj_get_image_pixel_size().
Corresponds to FPDFImageObj_GetImagePixelSize.
Sourcepub fn rotated_bounds(&self) -> Option<[Point; 4]>
pub fn rotated_bounds(&self) -> Option<[Point; 4]>
Returns the tight rotated bounding quadrilateral for this image object as 4 corner points in page coordinates.
The corners are computed by transforming the unit square
[0,0]–[1,1] through the image’s placement matrix, giving the
exact (possibly rotated) bounding quad.
Corresponds to FPDFPageObj_GetRotatedBounds.
Sourcepub fn page_obj_get_rotated_bounds(&self) -> Option<[Point; 4]>
pub fn page_obj_get_rotated_bounds(&self) -> Option<[Point; 4]>
Upstream-aligned alias for rotated_bounds().
Corresponds to FPDFPageObj_GetRotatedBounds.
Sourcepub fn get_rotated_bounds(&self) -> Option<[Point; 4]>
👎Deprecated: use page_obj_get_rotated_bounds() — matches upstream FPDFPageObj_GetRotatedBounds
pub fn get_rotated_bounds(&self) -> Option<[Point; 4]>
use page_obj_get_rotated_bounds() — matches upstream FPDFPageObj_GetRotatedBounds
Non-upstream alias — use page_obj_get_rotated_bounds().
Corresponds to FPDFPageObj_GetRotatedBounds.
Sourcepub fn rendered_bitmap(
&self,
_page_index: usize,
_scale: f32,
) -> Result<Bitmap, EditError>
pub fn rendered_bitmap( &self, _page_index: usize, _scale: f32, ) -> Result<Bitmap, EditError>
Returns the rendered bitmap for this image object at the given scale.
§Not Supported
Rendering a page object to bitmap requires a live CPDF_Document/CPDF_Page handle not available in rpdfium’s edit layer (read-only, ADR-002).
Corresponds to FPDFImageObj_GetRenderedBitmap.
Sourcepub fn image_obj_get_rendered_bitmap(
&self,
page_index: usize,
scale: f32,
) -> Result<Bitmap, EditError>
pub fn image_obj_get_rendered_bitmap( &self, page_index: usize, scale: f32, ) -> Result<Bitmap, EditError>
Upstream-aligned alias for rendered_bitmap().
Corresponds to FPDFImageObj_GetRenderedBitmap.
Sourcepub fn get_rendered_bitmap(
&self,
page_index: usize,
scale: f32,
) -> Result<Bitmap, EditError>
👎Deprecated: use image_obj_get_rendered_bitmap() — matches upstream FPDFImageObj_GetRenderedBitmap
pub fn get_rendered_bitmap( &self, page_index: usize, scale: f32, ) -> Result<Bitmap, EditError>
use image_obj_get_rendered_bitmap() — matches upstream FPDFImageObj_GetRenderedBitmap
Non-upstream alias — use image_obj_get_rendered_bitmap().
Corresponds to FPDFImageObj_GetRenderedBitmap.
Sourcepub fn icc_profile_data_decoded(&self) -> Option<&[u8]>
pub fn icc_profile_data_decoded(&self) -> Option<&[u8]>
Returns the decoded ICC profile bytes embedded in this image object, if any.
Returns None if the image has no embedded ICC profile.
ICC profile extraction requires parsing the image’s color space stream,
which is not performed at the edit layer.
Corresponds to FPDFImageObj_GetIccProfileDataDecoded.
Sourcepub fn image_obj_get_icc_profile_data_decoded(&self) -> Option<&[u8]>
pub fn image_obj_get_icc_profile_data_decoded(&self) -> Option<&[u8]>
Upstream-aligned alias for icc_profile_data_decoded().
Corresponds to FPDFImageObj_GetIccProfileDataDecoded.
Sourcepub fn get_icc_profile_data_decoded(&self) -> Option<&[u8]>
👎Deprecated: use image_obj_get_icc_profile_data_decoded() — matches upstream FPDFImageObj_GetIccProfileDataDecoded
pub fn get_icc_profile_data_decoded(&self) -> Option<&[u8]>
use image_obj_get_icc_profile_data_decoded() — matches upstream FPDFImageObj_GetIccProfileDataDecoded
Non-upstream alias — use image_obj_get_icc_profile_data_decoded().
Corresponds to FPDFImageObj_GetIccProfileDataDecoded.
Trait Implementations§
Source§impl Clone for ImageObject
impl Clone for ImageObject
Source§fn clone(&self) -> ImageObject
fn clone(&self) -> ImageObject
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more