Skip to main content

TiffWriter

Struct TiffWriter 

Source
pub struct TiffWriter { /* private fields */ }
Expand description

A TIFF file in memory, one page per TiffWriter::add_page: straight 8-bit RGBA, Deflate-compressed, each page with its resolution in dots per inch. It is neither Send nor Sync: the file and its encoder share one buffer through an Rc, so a writer stays on the thread that made it (the web reader’s worker has only one).

use laminapdf_render::TiffWriter;

let mut tiff = TiffWriter::new()?;
tiff.add_page(2, 1, &[255, 0, 0, 255, 0, 0, 255, 255], 300.0)?;
let file = tiff.finish();
assert!(file.starts_with(b"II*\0"));

Added in 0.3.0.

Implementations§

Source§

impl TiffWriter

Source

pub fn new() -> Result<Self, RenderError>

An empty file.

§Errors

RenderError::ExportFailed if the encoder can’t write the file’s header.

Added in 0.3.0.

Source

pub fn add_page( &mut self, width: u32, height: u32, rgba: &[u8], dpi: f64, ) -> Result<(), RenderError>

Adds a page of width × height straight RGBA pixels, row by row, drawn at dpi.

§Errors

RenderError::InvalidRequest when rgba isn’t width × height × 4 bytes or dpi isn’t a positive finite number; RenderError::ExportFailed if the encoder fails.

Added in 0.3.0.

Source

pub fn finish(self) -> Vec<u8> ⓘ

The file’s bytes.

Added in 0.3.0.

Trait Implementations§

Source§

impl Debug for TiffWriter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.