Struct pix::bgr::Bgr

source · []
pub struct Bgr {}
Expand description

BGR arrangement of RGB color model.

The components are blue, green, red and optional alpha.

Implementations

Get the blue component.

Example: Get BGR Blue
use pix::bgr::{Bgr, Bgr8};
use pix::chan::Ch8;

let p = Bgr8::new(0x93, 0x80, 0xA0);
assert_eq!(Bgr::blue(p), Ch8::new(0x93));

Get a mutable reference to the blue component.

Example: Modify BGR Blue
use pix::bgr::{Bgr, Bgr8};
use pix::chan::Ch8;

let mut p = Bgr8::new(0x88, 0x77, 0x66);
*Bgr::blue_mut(&mut p) = 0x55.into();
assert_eq!(Bgr::blue(p), Ch8::new(0x55));

Get the green component.

Example: BGR Green
use pix::bgr::{Bgr, Bgr16};
use pix::chan::Ch16;

let p = Bgr16::new(0x2000, 0x1234, 0x8000);
assert_eq!(Bgr::green(p), Ch16::new(0x1234));

Get a mutable reference to the green component.

Example: Modify BGR Green
use pix::bgr::{Bgr, Bgr16};
use pix::chan::Ch16;

let mut p = Bgr16::new(0x2000, 0x1234, 0x8000);
*Bgr::green_mut(&mut p) = 0x4321.into();
assert_eq!(Bgr::green(p), Ch16::new(0x4321));

Get the red component.

Example: BGR Red
use pix::bgr::{Bgr, Bgr32};
use pix::chan::Ch32;

let p = Bgr32::new(0.25, 0.5, 1.0);
assert_eq!(Bgr::red(p), Ch32::new(1.0));

Get a mutable reference to the red component.

Example: Modify BGR Red
use pix::bgr::{Bgr, Bgr32};
use pix::chan::Ch32;

let mut p = Bgr32::new(0.25, 0.5, 1.0);
*Bgr::red_mut(&mut p) = Ch32::new(0.75);
assert_eq!(Bgr::red(p), Ch32::new(0.75));

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Convert into red, green, blue and alpha components

Convert from red, green, blue and alpha components

Range of circular channel numbers

Range of linear channel numbers

Alpha channel number

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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 resulting type after obtaining ownership.

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

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

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.