Completeness / clipping
This is just to check if my observations are correct and I don't start implementing stuff in a fork that is already there.
Basically I have the need for a variant of Page::to_pixmap that allows for a clipping rectangle for zooming into an area. There doesn't seem to be a utility function in mupdf-c that implements that. In py-mupdf it was added in 2016 (https://github.com/pymupdf/PyMuPDF/issues/54).
I set out to implement the functionality in Rust, but could not find references to functions like fz_transform_rect and fz_round_rect.
My question boils down to:
- is there a variant of
to_pixmapavailable that allows for a clipping rectangle - if not, are the basic mupdf functions required to implement it available through mupdf-rs
but could not find references to functions like
fz_transform_rect
this? https://github.com/messense/mupdf-rs/blob/168fcb66297c43b4ba738593653f7c10770263e2/src/rect.rs#L188-L190
and https://docs.rs/mupdf-sys/latest/mupdf_sys/fn.fz_round_rect.html
Great. Exactly what I was looking for!
But why do I get
no method named `transform` found for struct `mupdf::Rect` in the current scope
method not found in `Rect`
is it not part of 0.5.0?
yes, it was added recently, if you want to contribute you should work with the current main branch.
I'm using:
let mut pixmap = Pixmap::new_with_rect(&Colorspace::device_rgb(), crop_rect, true)?;
pixmap.clear()?; // should not be necessary
let ctm = Matrix::default();
let device = Device::from_pixmap_with_clip(&pixmap, crop_rect)?;
page.run(&device, &ctm)?;