enum ImageSource {
Raster(DynamicImage),
Svg(ExternalXObject),
}Expand description
Enum representing either a raster image or a vector SVG image.
This enum allows the Image struct to handle both raster formats (PNG, JPEG, etc.)
and SVG vector graphics without rasterization, leveraging printpdf’s native SVG support.
Variants§
Raster(DynamicImage)
A raster image loaded from formats supported by the image crate.
Svg(ExternalXObject)
A vector SVG image parsed by printpdf as an ExternalXObject.
Implementations§
Source§impl ImageSource
impl ImageSource
Sourcefn intrinsic_size(&self, dpi: Option<f32>) -> Size
fn intrinsic_size(&self, dpi: Option<f32>) -> Size
Returns the intrinsic dimensions of the image in millimeters at the default DPI.
For raster images, dimensions are calculated from pixel count and DPI. For SVG images, dimensions are extracted from the ExternalXObject width and height.
§Arguments
dpi- Optional DPI override for raster images. Defaults to 300 DPI if not specified.
§Returns
A Size struct containing the width and height in millimeters.
Trait Implementations§
Source§impl Clone for ImageSource
impl Clone for ImageSource
Source§fn clone(&self) -> ImageSource
fn clone(&self) -> ImageSource
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ImageSource
impl RefUnwindSafe for ImageSource
impl Send for ImageSource
impl Sync for ImageSource
impl Unpin for ImageSource
impl UnwindSafe for ImageSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
Convert this type into
T, using the provided data to resolve any offsets.