pub struct ColorSpaceConversion;Expand description
Color space conversion operations
Implementations§
Source§impl ColorSpaceConversion
impl ColorSpaceConversion
Sourcepub fn rgb_to_yuv(
device: &GpuDevice,
input: &[u8],
output: &mut [u8],
width: u32,
height: u32,
color_space: ColorSpace,
) -> Result<()>
pub fn rgb_to_yuv( device: &GpuDevice, input: &[u8], output: &mut [u8], width: u32, height: u32, color_space: ColorSpace, ) -> Result<()>
Convert RGB to YUV
§Arguments
device- GPU deviceinput- Input RGB buffer (packed RGBA format)output- Output YUV buffer (packed YUVA format)width- Image widthheight- Image heightcolor_space- Color space standard (BT.601, BT.709, BT.2020)
§Errors
Returns an error if buffer sizes are invalid or if the GPU operation fails.
Sourcepub fn yuv_to_rgb(
device: &GpuDevice,
input: &[u8],
output: &mut [u8],
width: u32,
height: u32,
color_space: ColorSpace,
) -> Result<()>
pub fn yuv_to_rgb( device: &GpuDevice, input: &[u8], output: &mut [u8], width: u32, height: u32, color_space: ColorSpace, ) -> Result<()>
Convert YUV to RGB
§Arguments
device- GPU deviceinput- Input YUV buffer (packed YUVA format)output- Output RGB buffer (packed RGBA format)width- Image widthheight- Image heightcolor_space- Color space standard (BT.601, BT.709, BT.2020)
§Errors
Returns an error if buffer sizes are invalid or if the GPU operation fails.
Source§impl ColorSpaceConversion
impl ColorSpaceConversion
Sourcepub fn rgb_to_hsv(data: &[u8], width: u32, height: u32) -> Vec<u8> ⓘ
pub fn rgb_to_hsv(data: &[u8], width: u32, height: u32) -> Vec<u8> ⓘ
Convert interleaved RGBA pixels from RGB to HSV encoding.
Input layout: 4 bytes per pixel — R, G, B, A. Output layout: 4 bytes per pixel — H_enc, S_enc, V_enc, A (pass-through).
Encoding:
- H →
(H / 360.0 * 255.0) as u8(hue 0°–360° mapped to 0–255) - S →
(S * 255.0) as u8(saturation 0.0–1.0) - V →
(V * 255.0) as u8(value 0.0–1.0)
§Panics
Does not panic; invalid pixel counts are handled by truncating to complete 4-byte pixels.
Sourcepub fn hsv_to_rgb(data: &[u8], width: u32, height: u32) -> Vec<u8> ⓘ
pub fn hsv_to_rgb(data: &[u8], width: u32, height: u32) -> Vec<u8> ⓘ
Convert interleaved RGBA pixels from HSV to RGB encoding.
Input layout: 4 bytes per pixel — H_enc, S_enc, V_enc, A. Output layout: 4 bytes per pixel — R, G, B, A (pass-through).
Decoding: H = byte × 360 / 255, S = byte / 255, V = byte / 255.
Sourcepub fn rgb_to_lab(data: &[u8], width: u32, height: u32) -> Vec<u8> ⓘ
pub fn rgb_to_lab(data: &[u8], width: u32, height: u32) -> Vec<u8> ⓘ
Convert interleaved RGBA pixels from sRGB to CIE Lab*.
Input layout: 4 bytes per pixel — R, G, B, A. Output layout: 4 bytes per pixel:
- L* (0–100) → byte =
(L * 255.0 / 100.0) as u8 - a* (−128–127) → byte =
(a + 128.0) as u8(clamped 0–255) - b* (−128–127) → byte =
(b + 128.0) as u8(clamped 0–255) - A: pass-through
Sourcepub fn lab_to_rgb(data: &[u8], width: u32, height: u32) -> Vec<u8> ⓘ
pub fn lab_to_rgb(data: &[u8], width: u32, height: u32) -> Vec<u8> ⓘ
Convert interleaved RGBA pixels from CIE Lab* back to sRGB.
Input layout: 4 bytes per pixel — L_enc, a_enc, b_enc, A. Output layout: 4 bytes per pixel — R, G, B, A (pass-through).
Auto Trait Implementations§
impl Freeze for ColorSpaceConversion
impl RefUnwindSafe for ColorSpaceConversion
impl Send for ColorSpaceConversion
impl Sync for ColorSpaceConversion
impl Unpin for ColorSpaceConversion
impl UnsafeUnpin for ColorSpaceConversion
impl UnwindSafe for ColorSpaceConversion
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more