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
impl TiffWriter
Sourcepub fn new() -> Result<Self, RenderError>
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.
Sourcepub fn add_page(
&mut self,
width: u32,
height: u32,
rgba: &[u8],
dpi: f64,
) -> Result<(), RenderError>
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.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for TiffWriter
impl !Send for TiffWriter
impl !Sync for TiffWriter
impl !UnwindSafe for TiffWriter
impl Forget for TiffWriter
impl Freeze for TiffWriter
impl Move for TiffWriter
impl Unpin for TiffWriter
impl UnsafeUnpin for TiffWriter
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