pub struct YUVBuffer { /* private fields */ }Expand description
Converts RGB to YUV data.
Implementations§
Source§impl YUVBuffer
impl YUVBuffer
Sourcepub fn from_vec(yuv: Vec<u8>, width: usize, height: usize) -> Self
pub fn from_vec(yuv: Vec<u8>, width: usize, height: usize) -> Self
Creates a new YUV buffer from the given vec.
The vec’s length should be 3 * (width * height) / 2.
§Panics
May panic if the given sizes are not multiples of 2, or the yuv buffer’s size mismatches.
Sourcepub fn new(width: usize, height: usize) -> Self
pub fn new(width: usize, height: usize) -> Self
Allocates a new YUV buffer with the given width and height.
Both dimensions must be even.
§Panics
May panic if the given sizes are not multiples of 2.
Sourcepub fn from_rgb_source(rgb: impl RGBSource) -> Self
pub fn from_rgb_source(rgb: impl RGBSource) -> Self
Allocates a new YUV buffer with the given width and height and data.
§Panics
May panic if invoked with an RGB source where the dimensions are not multiples of 2.
Sourcepub fn from_rgb8_source(rgb: impl RGB8Source) -> Self
pub fn from_rgb8_source(rgb: impl RGB8Source) -> Self
Allocates a new YUV buffer with the given width and height and data.
This is the faster version of Self::from_rgb_source and you should generally
use this one.
§Panics
May panic if invoked with an RGB source where the dimensions are not multiples of 2.
Sourcepub fn read_rgb(&mut self, rgb: impl RGBSource)
pub fn read_rgb(&mut self, rgb: impl RGBSource)
Reads an RGB buffer, converts it to YUV and stores it.
§Panics
May panic if the given rgb does not match the internal format.
Sourcepub fn read_rgb8(&mut self, rgb: impl RGB8Source)
pub fn read_rgb8(&mut self, rgb: impl RGB8Source)
Reads an RGB8 buffer, converts it to YUV and stores it.
This is the faster version of Self::read_rgb and you should generally use this one.
§Panics
May panic if the given rgb does not match the internal format.