Struct agg::pixfmt::Pixfmt

source ·
pub struct Pixfmt<T> { /* private fields */ }
Expand description

Pixel Format Wrapper around raw pixel component data

Implementations

Create new Pixel Format of width * height * bpp

Allocates memory of width * height * bpp

Size of Rendering Buffer in bytes; width * height * bpp

Clear the Image

All color components are set to 255, including alpha if present

use agg::{Source,Pixfmt,Rgb8,Rgba8};

// Pixfmt with Rgb8, not Alpha Component
let mut pix = Pixfmt::<Rgb8>::new(2,2);
pix.clear();
let empty = Rgba8 { r:255, g:255, b:255, a:255};
assert_eq!(pix.get((0,0)), empty);
assert_eq!(pix.get((0,1)), empty);
assert_eq!(pix.get((1,0)), empty);
assert_eq!(pix.get((1,1)), empty);

// Pixfmt with Rgba8, including Alpha Component
let mut pix = Pixfmt::<Rgb8>::new(2,2);
pix.clear();
let empty = Rgba8 { r:255, g:255, b:255, a:255};
assert_eq!(pix.get((0,0)), empty);
assert_eq!(pix.get((0,1)), empty);
assert_eq!(pix.get((1,0)), empty);
assert_eq!(pix.get((1,1)), empty);

Copies the Color c to pixel at (x,y)

Locations outside of the region are igorned

use agg::{Source,Pixfmt,Rgba8};

let mut pix = Pixfmt::<Rgba8>::new(1,2);
let black = Rgba8::black();
pix.copy_pixel(0,1, black);
assert_eq!(pix.get((0,0)), Rgba8{r:0, g:0, b:0, a:0});
assert_eq!(pix.get((0,1)), black);

pix.copy_pixel(10,10, black); // Ignored, outside of range

Copies the Color c to pixels from (x,y) to (x+n-1,y)

Locations outside of the region are ignored

use agg::{Source,Pixfmt,Rgb8,Rgba8};

let mut pix = Pixfmt::<Rgb8>::new(10,1);
let black = Rgba8::black();
pix.copy_hline(0,0,10, black);
assert_eq!(pix.get((0,0)), black);
assert_eq!(pix.get((1,0)), black);
assert_eq!(pix.get((9,0)), black);

pix.copy_hline(1,1,10, black); // Ignored, outside of range

Copies the Color c to pixels from (x,y) to (x,y+n-1)

Locations outside of the region are ignored

use agg::{Source,Pixfmt,Rgba8,Rgba32};

let mut pix = Pixfmt::<Rgba32>::new(1,10);
let black  = Rgba32::new(0.,0.,0.,1.);
pix.copy_vline(0,0,10, black);

let black8 = Rgba8::from_trait(black); // pix.get() returns Rgba8
assert_eq!(pix.get((0,0)), black8);
assert_eq!(pix.get((0,1)), black8);
assert_eq!(pix.get((0,9)), black8);

pix.copy_vline(1,1,10, black); // Ignored, outside of range
👎Deprecated since 0.1.0: please use path_storage and friends instead

Draw a line from (x1,y1) to (x2,y2) of color c

Uses Xiaolin Wu’s line drawing algorithm which include Anti-Aliasing

👎Deprecated since 0.1.0: please use path_storage and friends instead

Draw a line from (x1,y1) to (x2,y2) of color c using a subpixel algorithm

Line is Aliased (not-anti-aliased)

👎Deprecated since 0.1.0: please use path_storage and friends instead

Draw a line from (x1,y1) to (x2,y2) of color c

Uses Bresenham’s line drawing algorithm

Trait Implementations

Formats the value using the given formatter. Read more

Height of rendering buffer in pixels

Width of rendering buffer in pixels

Height of rendering buffer in pixels

Width of rendering buffer in pixels

Height of rendering buffer in pixels

Width of rendering buffer in pixels

Height of rendering buffer in pixels

Width of rendering buffer in pixels

Height of rendering buffer in pixels

Width of rendering buffer in pixels

Access Pixeldata from a Pixfmt

Fill the data with the specified color
Copy or blend a pixel at id with color Read more
Copy or blend a pixel at id with color and a cover Read more
Copy or Blend a single color from (x,y) to (x+len-1,y) with cover Read more
Blend a single color from (x,y) to (x+len-1,y) with collection of covers Read more
Copy or Blend a single color from (x,y) to (x,y+len-1) with cover Read more
Blend a single color from (x,y) to (x,y+len-1) with collection of covers Read more
Blend a collection of colors from (x,y) to (x+len-1,y) with either a collection of covers or a single cover Read more
Blend a collection of colors from (x,y) to (x,y+len-1) with either a collection of covers or a single cover Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.