pub struct Image { /* private fields */ }Expand description
Represents an image that can be embedded in a PDF
Implementations§
Source§impl Image
impl Image
Sourcepub fn from_jpeg_file<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn from_jpeg_file<P: AsRef<Path>>(path: P) -> Result<Self>
Load a JPEG image from a file
Sourcepub fn from_jpeg_data(data: Vec<u8>) -> Result<Self>
pub fn from_jpeg_data(data: Vec<u8>) -> Result<Self>
Create an image from JPEG data
Sourcepub fn from_png_file<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn from_png_file<P: AsRef<Path>>(path: P) -> Result<Self>
Load a PNG image from a file
Sourcepub fn from_png_data(data: Vec<u8>) -> Result<Self>
pub fn from_png_data(data: Vec<u8>) -> Result<Self>
Create an image from PNG data with full transparency support
Sourcepub fn from_tiff_file<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn from_tiff_file<P: AsRef<Path>>(path: P) -> Result<Self>
Load a TIFF image from a file
Sourcepub fn from_tiff_data(data: Vec<u8>) -> Result<Self>
pub fn from_tiff_data(data: Vec<u8>) -> Result<Self>
Create an image from TIFF data
Sourcepub fn format(&self) -> ImageFormat
pub fn format(&self) -> ImageFormat
Get image format
Sourcepub fn bits_per_component(&self) -> u8
pub fn bits_per_component(&self) -> u8
Get bits per component
Sourcepub fn from_raw_data(
data: Vec<u8>,
width: u32,
height: u32,
color_space: ColorSpace,
bits_per_component: u8,
) -> Self
pub fn from_raw_data( data: Vec<u8>, width: u32, height: u32, color_space: ColorSpace, bits_per_component: u8, ) -> Self
Create image from raw RGB/Gray data (no encoding/compression)
Sourcepub fn from_rgba_data(
rgba_data: Vec<u8>,
width: u32,
height: u32,
) -> Result<Self>
pub fn from_rgba_data( rgba_data: Vec<u8>, width: u32, height: u32, ) -> Result<Self>
Create an image from RGBA data (with alpha channel)
Sourcepub fn from_gray_data(
gray_data: Vec<u8>,
width: u32,
height: u32,
) -> Result<Self>
pub fn from_gray_data( gray_data: Vec<u8>, width: u32, height: u32, ) -> Result<Self>
Create a grayscale image from gray data
Sourcepub fn from_file_raw<P: AsRef<Path>>(
path: P,
width: u32,
height: u32,
format: ImageFormat,
) -> Result<Self>
pub fn from_file_raw<P: AsRef<Path>>( path: P, width: u32, height: u32, format: ImageFormat, ) -> Result<Self>
Load raw image data from file (simple implementation without external image crate)
Sourcepub fn to_pdf_object(&self) -> Object
pub fn to_pdf_object(&self) -> Object
Convert to PDF XObject
Sourcepub fn to_pdf_object_with_transparency(&self) -> (Object, Option<Object>)
pub fn to_pdf_object_with_transparency(&self) -> (Object, Option<Object>)
Convert to PDF XObject with SMask for transparency
Sourcepub fn has_transparency(&self) -> bool
pub fn has_transparency(&self) -> bool
Check if this image has transparency
Sourcepub fn create_stencil_mask(&self, threshold: u8) -> Option<Image>
pub fn create_stencil_mask(&self, threshold: u8) -> Option<Image>
Create a stencil mask from this image A stencil mask uses 1-bit per pixel for transparency
Sourcepub fn create_mask(
&self,
mask_type: MaskType,
threshold: Option<u8>,
) -> Option<Image>
pub fn create_mask( &self, mask_type: MaskType, threshold: Option<u8>, ) -> Option<Image>
Create an image mask for transparency
Sourcepub fn alpha_data(&self) -> Option<&[u8]>
pub fn alpha_data(&self) -> Option<&[u8]>
Get the alpha data if present
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Image
impl RefUnwindSafe for Image
impl Send for Image
impl Sync for Image
impl Unpin for Image
impl UnwindSafe for Image
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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