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 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
Mutably borrows from an owned value. Read more