pub struct PdfPageImageObject<'a> { /* private fields */ }Expand description
A single PdfPageObject of type PdfPageObjectType::Image. The page object defines a single
bitmapped image.
Page objects can be created either attached to a PdfPage (in which case the page object’s
memory is owned by the containing page) or detached from any page (in which case the page
object’s memory is owned by the object). Page objects are not rendered until they are
attached to a page; page objects that are never attached to a page will be lost when they
fall out of scope.
The simplest way to create a page image object that is immediately attached to a page
is to call the PdfPageObjects::create_image_object() function.
Creating a detached page image object offers more scope for customization, but you must
add the object to a containing PdfPage manually. To create a detached page image object,
use the PdfPageImageObject::new() function. The detached page image object can later
be attached to a page by using the PdfPageObjects::add_image_object() function.
Implementations
sourceimpl<'a> PdfPageImageObject<'a>
impl<'a> PdfPageImageObject<'a>
sourcepub fn new(
document: &PdfDocument<'a>,
image: DynamicImage
) -> Result<Self, PdfiumError>
pub fn new(
document: &PdfDocument<'a>,
image: DynamicImage
) -> Result<Self, PdfiumError>
Creates a new PdfPageImageObject from the given arguments. The returned page object
will not be rendered until it is added to a PdfPage using the
PdfPageObjects::add_image_object() function.
The returned page object will have its width and height both set to 1.0 points. Use the PdfPageObjectCommon::scale() function to apply a horizontal and vertical scale to the object after it is created, or use one of the PdfPageImageObject::new_with_width(), PdfPageImageObject::new_with_height(), or PdfPageImageObject::new_with_size() functions to scale the page object to a specific width and/or height at the time the object is created.
sourcepub fn new_with_width(
document: &PdfDocument<'a>,
image: DynamicImage,
width: PdfPoints
) -> Result<Self, PdfiumError>
pub fn new_with_width(
document: &PdfDocument<'a>,
image: DynamicImage,
width: PdfPoints
) -> Result<Self, PdfiumError>
Creates a new PdfPageImageObject from the given arguments. The page object will be scaled
horizontally to match the given width; its height will be adjusted to maintain the aspect
ratio of the given image. The returned page object will not be rendered until it is
added to a PdfPage using the PdfPageObjects::add_image_object() function.
sourcepub fn new_with_height(
document: &PdfDocument<'a>,
image: DynamicImage,
height: PdfPoints
) -> Result<Self, PdfiumError>
pub fn new_with_height(
document: &PdfDocument<'a>,
image: DynamicImage,
height: PdfPoints
) -> Result<Self, PdfiumError>
Creates a new PdfPageImageObject from the given arguments. The page object will be scaled
vertically to match the given height; its width will be adjusted to maintain the aspect
ratio of the given image. The returned page object will not be rendered until it is
added to a PdfPage using the PdfPageObjects::add_image_object() function.
sourcepub fn new_with_size(
document: &PdfDocument<'a>,
image: DynamicImage,
width: PdfPoints,
height: PdfPoints
) -> Result<Self, PdfiumError>
pub fn new_with_size(
document: &PdfDocument<'a>,
image: DynamicImage,
width: PdfPoints,
height: PdfPoints
) -> Result<Self, PdfiumError>
Creates a new PdfPageImageObject from the given arguments. The page object will be scaled to
match the given width and height. The returned page object will not be rendered until it is
added to a PdfPage using the PdfPageObjects::add_image_object() function.
sourcepub fn get_raw_image(&self) -> Result<DynamicImage, PdfiumError>
pub fn get_raw_image(&self) -> Result<DynamicImage, PdfiumError>
Returns a new Image::DynamicImage created from the bitmap buffer backing
this PdfPageImageObject, ignoring any image filters, image mask, or object
transforms applied to this page object.
sourcepub fn get_processed_image(
&self,
document: &PdfDocument<'_>
) -> Result<DynamicImage, PdfiumError>
pub fn get_processed_image(
&self,
document: &PdfDocument<'_>
) -> Result<DynamicImage, PdfiumError>
Returns a new Image::DynamicImage created from the bitmap buffer backing
this PdfPageImageObject, taking into account any image filters, image mask, and
object transforms applied to this page object.
sourcepub fn set_image(&mut self, image: DynamicImage) -> Result<(), PdfiumError>
pub fn set_image(&mut self, image: DynamicImage) -> Result<(), PdfiumError>
Applies the byte data in the given Image::DynamicImage to this PdfPageImageObject.
sourcepub fn set_bitmap(&mut self, bitmap: &PdfBitmap<'_>) -> Result<(), PdfiumError>
pub fn set_bitmap(&mut self, bitmap: &PdfBitmap<'_>) -> Result<(), PdfiumError>
Applies the byte data in the given PdfBitmap to this PdfPageImageObject.
sourcepub fn horizontal_dpi(&self) -> Result<f32, PdfiumError>
pub fn horizontal_dpi(&self) -> Result<f32, PdfiumError>
Returns the horizontal dots per inch resolution of the image assigned to this PdfPageImageObject, based on the intrinsic resolution of the assigned image and the dimensions of this object.
sourcepub fn vertical_dpi(&self) -> Result<f32, PdfiumError>
pub fn vertical_dpi(&self) -> Result<f32, PdfiumError>
Returns the vertical dots per inch resolution of the image assigned to this PdfPageImageObject, based on the intrinsic resolution of the assigned image and the dimensions of this object.
sourcepub fn bits_per_pixel(&self) -> Result<u8, PdfiumError>
pub fn bits_per_pixel(&self) -> Result<u8, PdfiumError>
Returns the bits per pixel for the image assigned to this PdfPageImageObject.
This value is not available if this object has not been attached to a PdfPage.
sourcepub fn color_space(&self) -> Result<PdfColorSpace, PdfiumError>
pub fn color_space(&self) -> Result<PdfColorSpace, PdfiumError>
Returns the color space for the image assigned to this PdfPageImageObject.
This value is not available if this object has not been attached to a PdfPage.
sourcepub fn filters(&self) -> PdfPageImageObjectFilters<'_>
pub fn filters(&self) -> PdfPageImageObjectFilters<'_>
Returns the collection of image filters currently applied to this PdfPageImageObject.
Trait Implementations
sourceimpl<'a> From<PdfPageImageObject<'a>> for PdfPageObject<'a>
impl<'a> From<PdfPageImageObject<'a>> for PdfPageObject<'a>
sourcefn from(object: PdfPageImageObject<'a>) -> Self
fn from(object: PdfPageImageObject<'a>) -> Self
Auto Trait Implementations
impl<'a> !RefUnwindSafe for PdfPageImageObject<'a>
impl<'a> !Send for PdfPageImageObject<'a>
impl<'a> !Sync for PdfPageImageObject<'a>
impl<'a> Unpin for PdfPageImageObject<'a>
impl<'a> !UnwindSafe for PdfPageImageObject<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<'a, T> PdfPageObjectCommon<'a> for Twhere
T: PdfPageObjectPrivate<'a>,
impl<'a, T> PdfPageObjectCommon<'a> for Twhere
T: PdfPageObjectPrivate<'a>,
sourcefn has_transparency(&self) -> bool
fn has_transparency(&self) -> bool
true if this PdfPageObject contains transparency.sourcefn bounds(&self) -> Result<PdfRect, PdfiumError>
fn bounds(&self) -> Result<PdfRect, PdfiumError>
sourcefn transform(
&mut self,
a: f64,
b: f64,
c: f64,
d: f64,
e: f64,
f: f64
) -> Result<(), PdfiumError>
fn transform(
&mut self,
a: f64,
b: f64,
c: f64,
d: f64,
e: f64,
f: f64
) -> Result<(), PdfiumError>
sourcefn transform_from(
&mut self,
other: &PdfPageObject<'_>
) -> Result<(), PdfiumError>
fn transform_from(
&mut self,
other: &PdfPageObject<'_>
) -> Result<(), PdfiumError>
sourcefn get_horizontal_translation(&self) -> PdfPoints
fn get_horizontal_translation(&self) -> PdfPoints
sourcefn get_vertical_translation(&self) -> PdfPoints
fn get_vertical_translation(&self) -> PdfPoints
sourcefn get_horizontal_scale(&self) -> f64
fn get_horizontal_scale(&self) -> f64
sourcefn get_vertical_scale(&self) -> f64
fn get_vertical_scale(&self) -> f64
sourcefn get_rotation_counter_clockwise_radians(&self) -> f32
fn get_rotation_counter_clockwise_radians(&self) -> f32
sourcefn get_x_axis_skew_radians(&self) -> f32
fn get_x_axis_skew_radians(&self) -> f32
sourcefn get_y_axis_skew_radians(&self) -> f32
fn get_y_axis_skew_radians(&self) -> f32
sourcefn set_blend_mode(
&mut self,
blend_mode: PdfPageObjectBlendMode
) -> Result<(), PdfiumError>
fn set_blend_mode(
&mut self,
blend_mode: PdfPageObjectBlendMode
) -> Result<(), PdfiumError>
sourcefn fill_color(&self) -> Result<PdfColor, PdfiumError>
fn fill_color(&self) -> Result<PdfColor, PdfiumError>
sourcefn set_fill_color(&mut self, fill_color: PdfColor) -> Result<(), PdfiumError>
fn set_fill_color(&mut self, fill_color: PdfColor) -> Result<(), PdfiumError>
sourcefn stroke_color(&self) -> Result<PdfColor, PdfiumError>
fn stroke_color(&self) -> Result<PdfColor, PdfiumError>
sourcefn set_stroke_color(&mut self, stroke_color: PdfColor) -> Result<(), PdfiumError>
fn set_stroke_color(&mut self, stroke_color: PdfColor) -> Result<(), PdfiumError>
sourcefn stroke_width(&self) -> Result<PdfPoints, PdfiumError>
fn stroke_width(&self) -> Result<PdfPoints, PdfiumError>
sourcefn set_stroke_width(
&mut self,
stroke_width: PdfPoints
) -> Result<(), PdfiumError>
fn set_stroke_width(
&mut self,
stroke_width: PdfPoints
) -> Result<(), PdfiumError>
sourcefn line_join(&self) -> Result<PdfPageObjectLineJoin, PdfiumError>
fn line_join(&self) -> Result<PdfPageObjectLineJoin, PdfiumError>
sourcefn set_line_join(
&mut self,
line_join: PdfPageObjectLineJoin
) -> Result<(), PdfiumError>
fn set_line_join(
&mut self,
line_join: PdfPageObjectLineJoin
) -> Result<(), PdfiumError>
sourcefn line_cap(&self) -> Result<PdfPageObjectLineCap, PdfiumError>
fn line_cap(&self) -> Result<PdfPageObjectLineCap, PdfiumError>
sourcefn set_line_cap(
&mut self,
line_cap: PdfPageObjectLineCap
) -> Result<(), PdfiumError>
fn set_line_cap(
&mut self,
line_cap: PdfPageObjectLineCap
) -> Result<(), PdfiumError>
sourcefn width(&self) -> Result<PdfPoints, PdfiumError>
fn width(&self) -> Result<PdfPoints, PdfiumError>
sourcefn height(&self) -> Result<PdfPoints, PdfiumError>
fn height(&self) -> Result<PdfPoints, PdfiumError>
sourcefn is_inside_rect(&self, rect: &PdfRect) -> bool
fn is_inside_rect(&self, rect: &PdfRect) -> bool
true if the bounds of this PdfPageObject lie entirely within the given rectangle.sourcefn does_overlap_rect(&self, rect: &PdfRect) -> bool
fn does_overlap_rect(&self, rect: &PdfRect) -> bool
true if the bounds of this PdfPageObject lie at least partially within
the given rectangle. Read more