Trait plotters_bitmap::bitmap_pixel::PixelFormat[][src]

pub trait PixelFormat: Sized {
    const PIXEL_SIZE: usize;
    const EFFECTIVE_PIXEL_SIZE: usize;

    fn byte_at(r: u8, g: u8, b: u8, a: u64, idx: usize) -> u8;
fn decode_pixel(data: &[u8]) -> (u8, u8, u8, u64);
fn blend_rect_fast(
        target: &mut BitMapBackend<'_, Self>,
        upper_left: (i32, i32),
        bottom_right: (i32, i32),
        r: u8,
        g: u8,
        b: u8,
        a: f64
    );
fn fill_rect_fast(
        target: &mut BitMapBackend<'_, Self>,
        upper_left: (i32, i32),
        bottom_right: (i32, i32),
        r: u8,
        g: u8,
        b: u8
    ); fn fill_vertical_line_fast(
        target: &mut BitMapBackend<'_, Self>,
        x: i32,
        ys: (i32, i32),
        r: u8,
        g: u8,
        b: u8
    ) { ... }
fn draw_pixel(
        target: &mut BitMapBackend<'_, Self>,
        point: (i32, i32),
        (r, g, b): (u8, u8, u8),
        alpha: f64
    ) { ... }
fn can_be_saved() -> bool { ... } }
Expand description

The trait that describes some details about a particular pixel format

Associated Constants

const PIXEL_SIZE: usize[src]

Number of bytes per pixel

const EFFECTIVE_PIXEL_SIZE: usize[src]

Number of effective bytes per pixel, e.g. for BGRX pixel format, the size of pixel is 4 but the effective size is 3, since the 4th byte isn’t used

Required methods

fn byte_at(r: u8, g: u8, b: u8, a: u64, idx: usize) -> u8[src]

Encoding a pixel and returns the idx-th byte for the pixel

fn decode_pixel(data: &[u8]) -> (u8, u8, u8, u64)[src]

Decode a pixel at the given location

fn blend_rect_fast(
    target: &mut BitMapBackend<'_, Self>,
    upper_left: (i32, i32),
    bottom_right: (i32, i32),
    r: u8,
    g: u8,
    b: u8,
    a: f64
)
[src]

The fast alpha blending algorithm for this pixel format

  • target: The target bitmap backend
  • upper_left: The upper-left coord for the rect
  • bottom_right: The bottom-right coord for the rect
  • r, g, b, a: The blending color and alpha value

fn fill_rect_fast(
    target: &mut BitMapBackend<'_, Self>,
    upper_left: (i32, i32),
    bottom_right: (i32, i32),
    r: u8,
    g: u8,
    b: u8
)
[src]

The fast rectangle filling algorithm

  • target: The target bitmap backend
  • upper_left: The upper-left coord for the rect
  • bottom_right: The bottom-right coord for the rect
  • r, g, b: The filling color

Provided methods

fn fill_vertical_line_fast(
    target: &mut BitMapBackend<'_, Self>,
    x: i32,
    ys: (i32, i32),
    r: u8,
    g: u8,
    b: u8
)
[src]

The fast vertical line filling algorithm

  • target: The target bitmap backend
  • x: the X coordinate for the entire line
  • ys: The range of y coord
  • r, g, b: The blending color and alpha value

fn draw_pixel(
    target: &mut BitMapBackend<'_, Self>,
    point: (i32, i32),
    (r, g, b): (u8, u8, u8),
    alpha: f64
)
[src]

Drawing a single pixel in this format

  • target: The target bitmap backend
  • point: The coord of the point
  • r, g, b: The filling color
  • alpha: The alpha value

fn can_be_saved() -> bool[src]

Indicates if this pixel format can be saved as image. Note: Currently we only using RGB pixel format in the image crate, but later we may lift this restriction

  • returns: If the image can be saved as image file

Implementors

impl PixelFormat for BGRXPixel[src]

const PIXEL_SIZE: usize[src]

const EFFECTIVE_PIXEL_SIZE: usize[src]

fn byte_at(r: u8, g: u8, b: u8, _a: u64, idx: usize) -> u8[src]

fn decode_pixel(data: &[u8]) -> (u8, u8, u8, u64)[src]

fn blend_rect_fast(
    target: &mut BitMapBackend<'_, Self>,
    upper_left: (i32, i32),
    bottom_right: (i32, i32),
    r: u8,
    g: u8,
    b: u8,
    a: f64
)
[src]

fn fill_rect_fast(
    target: &mut BitMapBackend<'_, Self>,
    upper_left: (i32, i32),
    bottom_right: (i32, i32),
    r: u8,
    g: u8,
    b: u8
)
[src]

impl PixelFormat for RGBPixel[src]

const PIXEL_SIZE: usize[src]

const EFFECTIVE_PIXEL_SIZE: usize[src]

fn byte_at(r: u8, g: u8, b: u8, _a: u64, idx: usize) -> u8[src]

fn decode_pixel(data: &[u8]) -> (u8, u8, u8, u64)[src]

fn can_be_saved() -> bool[src]

fn blend_rect_fast(
    target: &mut BitMapBackend<'_, Self>,
    upper_left: (i32, i32),
    bottom_right: (i32, i32),
    r: u8,
    g: u8,
    b: u8,
    a: f64
)
[src]

fn fill_rect_fast(
    target: &mut BitMapBackend<'_, Self>,
    upper_left: (i32, i32),
    bottom_right: (i32, i32),
    r: u8,
    g: u8,
    b: u8
)
[src]