Struct pdfium_render::bitmap::PdfBitmap
source · pub struct PdfBitmap<'a> { /* private fields */ }Expand description
A bitmap image with a specific width and height.
Implementations§
source§impl<'a> PdfBitmap<'a>
impl<'a> PdfBitmap<'a>
sourcepub fn empty(
width: Pixels,
height: Pixels,
format: PdfBitmapFormat,
bindings: &'a dyn PdfiumLibraryBindings
) -> Result<PdfBitmap<'_>, PdfiumError>
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.
sourcepub fn bindings(&self) -> &dyn PdfiumLibraryBindings
pub fn bindings(&self) -> &dyn PdfiumLibraryBindings
Returns the PdfiumLibraryBindings used by this PdfBitmap.
sourcepub fn width(&self) -> Pixels
pub fn width(&self) -> Pixels
Returns the width of the image in the bitmap buffer backing this PdfBitmap.
sourcepub fn height(&self) -> Pixels
pub fn height(&self) -> Pixels
Returns the height of the image in the bitmap buffer backing this PdfBitmap.
sourcepub fn format(&self) -> Result<PdfBitmapFormat, PdfiumError>
pub fn format(&self) -> Result<PdfBitmapFormat, PdfiumError>
Returns the pixel format of the image in the bitmap buffer backing this PdfBitmap.
sourcepub fn as_bytes(&self) -> &'a [u8] ⓘ
pub fn as_bytes(&self) -> &'a [u8] ⓘ
Returns an immutable reference to the bitmap buffer backing this PdfBitmap.
sourcepub fn as_image(&self) -> DynamicImage
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.
sourcepub fn as_array(&self) -> Uint8Array
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.
sourcepub fn as_image_data(&self) -> Result<ImageData, JsValue>
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.