pub struct PdfiumBitmap { /* private fields */ }Expand description
Rust interface to FPDF_BITMAP
Implementations§
Source§impl PdfiumBitmap
impl PdfiumBitmap
Sourcepub fn empty(
width: i32,
height: i32,
format: PdfiumBitmapFormat,
) -> PdfiumResult<Self>
pub fn empty( width: i32, height: i32, format: PdfiumBitmapFormat, ) -> PdfiumResult<Self>
Creates a new PdfiumBitmap with the given width, height and PdfiumBitmapFormat.
Sourcepub fn fill(&self, color: &PdfiumColor)
pub fn fill(&self, color: &PdfiumColor)
Fills this entire PdfiumBitmap with the given PdfiumColor.
Sourcepub fn width(&self) -> i32
pub fn width(&self) -> i32
Returns the width of the image in the bitmap buffer backing this PdfiumBitmap.
Sourcepub fn height(&self) -> i32
pub fn height(&self) -> i32
Returns the height of the image in the bitmap buffer backing this PdfiumBitmap.
Sourcepub fn format(&self) -> PdfiumBitmapFormat
pub fn format(&self) -> PdfiumBitmapFormat
Returns the pixel format of the image in the bitmap buffer backing this PdfiumBitmap.
Sourcepub fn as_raw_bytes<'a>(&self, lib: &'a PdfiumGuard) -> &'a [u8] ⓘ
pub fn as_raw_bytes<'a>(&self, lib: &'a PdfiumGuard) -> &'a [u8] ⓘ
Returns an immutable reference to the bitmap buffer backing this PdfiumBitmap.
This function does not attempt any color channel normalization.
Sourcepub fn as_rgba_bytes(&self) -> PdfiumResult<Vec<u8>>
pub fn as_rgba_bytes(&self) -> PdfiumResult<Vec<u8>>
Returns an owned copy of the bitmap buffer backing this PdfiumBitmap as RGBA.
Normalizing all color channels into RGBA irrespective of the original pixel format.
Sourcepub fn as_image(&self) -> PdfiumResult<DynamicImage>
pub fn as_image(&self) -> PdfiumResult<DynamicImage>
Returns a copy of this a bitmap as a DynamicImage::ImageRgba8
Sourcepub fn save(&self, path: &str, format: ImageFormat) -> PdfiumResult<()>
pub fn save(&self, path: &str, format: ImageFormat) -> PdfiumResult<()>
Saves this bitmap to the given path.
As the underlying image contains an alpha channel, the ImageFormat needs to support it.
Trait Implementations§
Source§impl Drop for PdfiumBitmap
impl Drop for PdfiumBitmap
Source§fn drop(&mut self)
fn drop(&mut self)
Closes this PdfiumBitmap, releasing held memory.
Source§impl From<&PdfiumBitmap> for FPDF_BITMAP
impl From<&PdfiumBitmap> for FPDF_BITMAP
Source§fn from(value: &PdfiumBitmap) -> Self
fn from(value: &PdfiumBitmap) -> Self
Source§impl From<&mut PdfiumBitmap> for FPDF_BITMAP
impl From<&mut PdfiumBitmap> for FPDF_BITMAP
Source§fn from(value: &mut PdfiumBitmap) -> Self
fn from(value: &mut PdfiumBitmap) -> Self
Auto Trait Implementations§
impl Freeze for PdfiumBitmap
impl RefUnwindSafe for PdfiumBitmap
impl !Send for PdfiumBitmap
impl !Sync for PdfiumBitmap
impl Unpin for PdfiumBitmap
impl UnwindSafe for PdfiumBitmap
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> 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