pub struct Pixmap { /* private fields */ }
Expand description
Pixmaps (pixel maps) are objects at the heart of MuPDF’s rendering capabilities.
They represent plane rectangular sets of pixels. Each pixel is described by a number of bytes (components) defining its color, plus an optional alpha byte defining its transparency.
Implementations§
source§impl Pixmap
impl Pixmap
sourcepub fn new(
cs: &Colorspace,
x: i32,
y: i32,
w: i32,
h: i32,
alpha: bool
) -> Result<Self, Error>
pub fn new( cs: &Colorspace, x: i32, y: i32, w: i32, h: i32, alpha: bool ) -> Result<Self, Error>
Create an empty pixmap of size and origin.
Note that the image area is not initialized and will contain crap data
sourcepub fn new_with_rect(
cs: &Colorspace,
rect: IRect,
alpha: bool
) -> Result<Self, Error>
pub fn new_with_rect( cs: &Colorspace, rect: IRect, alpha: bool ) -> Result<Self, Error>
Create an empty pixmap of size and origin given by the rectangle.
Note that the image area is not initialized and will contain crap data
sourcepub fn new_with_w_h(
cs: &Colorspace,
w: i32,
h: i32,
alpha: bool
) -> Result<Self, Error>
pub fn new_with_w_h( cs: &Colorspace, w: i32, h: i32, alpha: bool ) -> Result<Self, Error>
Create an empty pixmap of size with origin set to (0, 0)
.
Note that the image area is not initialized and will contain crap data
sourcepub fn stride(&self) -> isize
pub fn stride(&self) -> isize
Contains the length of one row of image data in Pixmap samples.
This is primarily used for calculation purposes. The following expressions are true:
samples.len() == height * stride
width * n == stride
pub fn color_space(&self) -> Option<Colorspace>
sourcepub fn resolution(&self) -> (i32, i32)
pub fn resolution(&self) -> (i32, i32)
Horizontal and vertical resolution in dpi (dots per inch).
pub fn set_resolution(&mut self, x_res: i32, y_res: i32)
pub fn rect(&self) -> IRect
pub fn samples(&self) -> &[u8] ⓘ
pub fn samples_mut(&mut self) -> &mut [u8] ⓘ
sourcepub fn clear_with(&mut self, value: i32) -> Result<(), Error>
pub fn clear_with(&mut self, value: i32) -> Result<(), Error>
Initialize the samples area
§Params
value
- values from 0 to 255 are valid. Each color byte of each pixel will be set to this value, while alpha will be set to 255 (non-transparent) if present
pub fn save_as(&self, filename: &str, format: ImageFormat) -> Result<(), Error>
pub fn invert(&mut self) -> Result<(), Error>
sourcepub fn gamma(&mut self, gamma: f32) -> Result<(), Error>
pub fn gamma(&mut self, gamma: f32) -> Result<(), Error>
Apply a gamma factor to a pixmap, i.e. lighten or darken it.
Pixmaps with no colorspace are ignored
§Params
gamma
- gamma = 1.0 does nothing, gamma < 1.0 lightens, gamma > 1.0 darkens the image.