Skip to main content

graphicx_crop_rect

Function graphicx_crop_rect 

Source
pub fn graphicx_crop_rect(
    w: u32,
    h: u32,
    op: &GraphicxOp,
    px_per_bp: f64,
) -> Option<(u32, u32, u32, u32)>
Expand description

The pixel rectangle a trim/viewport op keeps of a w×h raster, as (x, y, width, height) from its top-left corner; None when the box keeps the whole image or no pixel of it. Port of Perl image_graphicx_complex’s trim/clip arm (Util/Image.pm L400-418): TeX measures the box from the lower-left corner and ImageMagick from the upper-left, and the box is clamped to the image, never padded. px_per_bp is the raster’s own resolution over 72 (DIVERGENCES #337: Perl divides by 72.27 and reads the resolution without its unit).