Struct mupdf::pixmap::Pixmap

source ·
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

source

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

source

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

source

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

source

pub fn x(&self) -> i32

X-coordinate of top-left corner

source

pub fn y(&self) -> i32

Y-coordinate of top-left corner

source

pub fn origin(&self) -> (i32, i32)

Pixmap origin, (x, y)

source

pub fn width(&self) -> u32

Width of the region in pixels.

source

pub fn height(&self) -> u32

Height of the region in pixels.

source

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
source

pub fn n(&self) -> u8

Number of components per pixel.

source

pub fn alpha(&self) -> bool

Indicates whether the pixmap contains transparency information.

source

pub fn color_space(&self) -> Option<Colorspace>

source

pub fn resolution(&self) -> (i32, i32)

Horizontal and vertical resolution in dpi (dots per inch).

source

pub fn set_resolution(&mut self, x_res: i32, y_res: i32)

source

pub fn rect(&self) -> IRect

source

pub fn samples(&self) -> &[u8]

source

pub fn samples_mut(&mut self) -> &mut [u8]

source

pub fn pixels(&self) -> Option<&[u32]>

Only valid for RGBA or BGRA pixmaps

source

pub fn clear(&mut self) -> Result<(), Error>

Initialize the samples area with 0x00

source

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
source

pub fn save_as(&self, filename: &str, format: ImageFormat) -> Result<(), Error>

source

pub fn invert(&mut self) -> Result<(), Error>

source

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.
source

pub fn tint(&mut self, black: i32, white: i32) -> Result<(), Error>

Tint pixmap with color

source

pub fn write_to<W: Write>( &self, w: &mut W, format: ImageFormat ) -> Result<u64, Error>

source

pub fn try_clone(&self) -> Result<Self, Error>

Trait Implementations§

source§

impl Clone for Pixmap

source§

fn clone(&self) -> Pixmap

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Pixmap

source§

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

Formats the value using the given formatter. Read more
source§

impl Drop for Pixmap

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl TryFrom<Pixmap> for Bitmap

§

type Error = Error

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

fn try_from(pixmap: Pixmap) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Pixmap

§

impl RefUnwindSafe for Pixmap

§

impl !Send for Pixmap

§

impl !Sync for Pixmap

§

impl Unpin for Pixmap

§

impl UnwindSafe for Pixmap

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<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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.