pub struct PdfBitmap<'a> { /* private fields */ }
Expand description

A bitmap image with a specific width and height.

Implementations§

source§

impl<'a> PdfBitmap<'a>

source

pub fn empty( width: Pixels, height: Pixels, format: PdfBitmapFormat, bindings: &'a dyn PdfiumLibraryBindings ) -> Result<PdfBitmap<'_>, PdfiumError>

Creates an empty PdfBitmap with a buffer capable of storing an image of the given pixel width and height in the given pixel format.

source

pub fn bindings(&self) -> &dyn PdfiumLibraryBindings

Returns the PdfiumLibraryBindings used by this PdfBitmap.

source

pub fn width(&self) -> Pixels

Returns the width of the image in the bitmap buffer backing this PdfBitmap.

source

pub fn height(&self) -> Pixels

Returns the height of the image in the bitmap buffer backing this PdfBitmap.

source

pub fn format(&self) -> Result<PdfBitmapFormat, PdfiumError>

Returns the pixel format of the image in the bitmap buffer backing this PdfBitmap.

source

pub fn as_bytes(&self) -> &'a [u8]

Returns an immutable reference to the bitmap buffer backing this PdfBitmap.

source

pub fn as_image(&self) -> DynamicImage

Returns a new Image::DynamicImage created from the bitmap buffer backing this PdfBitmap.

This function is only available when this crate’s image feature is enabled.

source

pub fn as_array(&self) -> Uint8Array

Returns a Javascript Uint8Array object representing the bitmap buffer backing this PdfBitmap.

This function avoids a memory allocation and copy required by both PdfBitmap::as_bytes() and PdfBitmap::as_image_data(), making it preferable for situations where performance is paramount.

This function is only available when compiling to WASM.

source

pub fn as_image_data(&self) -> Result<ImageData, JsValue>

Returns a new Javascript ImageData object created from the bitmap buffer backing this PdfBitmap. The resulting ImageData can be easily displayed in an HTML <canvas> element like so:

canvas.getContext('2d').putImageData(image_data);

This function is slower than calling PdfBitmap::as_array() because it must perform an additional memory allocation in order to create the ImageData object. Consider calling the PdfBitmap::as_array() function directly if performance is paramount.

This function is only available when compiling to WASM.

Trait Implementations§

source§

impl<'a> Drop for PdfBitmap<'a>

source§

fn drop(&mut self)

Closes this PdfBitmap, releasing the memory held by the bitmap buffer.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for PdfBitmap<'a>

§

impl<'a> !Send for PdfBitmap<'a>

§

impl<'a> !Sync for PdfBitmap<'a>

§

impl<'a> Unpin for PdfBitmap<'a>

§

impl<'a> !UnwindSafe for PdfBitmap<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.