pub struct PixelFormat {
pub bits_per_pixel: u8,
pub depth: u8,
pub big_endian_flag: u8,
pub true_colour_flag: u8,
pub red_max: u16,
pub green_max: u16,
pub blue_max: u16,
pub red_shift: u8,
pub green_shift: u8,
pub blue_shift: u8,
}Expand description
Represents the pixel format used in RFB protocol.
This struct defines how pixel data is interpreted, including color depth, endianness, and RGB component details.
Fields§
§bits_per_pixel: u8Number of bits per pixel.
depth: u8Depth of the pixel in bits.
big_endian_flag: u8Flag indicating if the pixel data is big-endian (1) or little-endian (0).
true_colour_flag: u8Flag indicating if the pixel format is true-colour (1) or colormapped (0).
red_max: u16Maximum red color value.
green_max: u16Maximum green color value.
blue_max: u16Maximum blue color value.
red_shift: u8Number of shifts to apply to get the red color component.
green_shift: u8Number of shifts to apply to get the green color component.
blue_shift: u8Number of shifts to apply to get the blue color component.
Implementations§
Source§impl PixelFormat
impl PixelFormat
Sourcepub fn rgba32() -> Self
pub fn rgba32() -> Self
Creates a standard 32-bit RGBA pixel format.
§Returns
A PixelFormat instance configured for 32-bit RGBA.
Sourcepub fn is_compatible_with_rgba32(&self) -> bool
pub fn is_compatible_with_rgba32(&self) -> bool
Checks if this PixelFormat is compatible with the standard 32-bit RGBA format.
§Returns
true if the pixel format matches 32-bit RGBA, false otherwise.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Validates that this pixel format is supported.
Checks that the format uses valid bits-per-pixel values and is either true-color or a supported color-mapped format.
§Returns
true if the format is valid and supported, false otherwise.
Sourcepub fn rgb565() -> Self
pub fn rgb565() -> Self
Creates a 16-bit RGB565 pixel format.
RGB565 uses 5 bits for red, 6 bits for green, and 5 bits for blue. This is a common format for embedded displays and bandwidth-constrained clients.
§Returns
A PixelFormat instance configured for 16-bit RGB565.
Sourcepub fn rgb555() -> Self
pub fn rgb555() -> Self
Creates a 16-bit RGB555 pixel format.
RGB555 uses 5 bits for each of red, green, and blue, with 1 unused bit.
§Returns
A PixelFormat instance configured for 16-bit RGB555.
Sourcepub fn bgr233() -> Self
pub fn bgr233() -> Self
Creates an 8-bit BGR233 pixel format.
BGR233 uses 2 bits for blue, 3 bits for green, and 3 bits for red. This format is used for very low bandwidth connections and legacy clients.
§Returns
A PixelFormat instance configured for 8-bit BGR233.
Sourcepub fn write_to(&self, buf: &mut BytesMut)
pub fn write_to(&self, buf: &mut BytesMut)
Writes the pixel format data into a BytesMut buffer.
This function serializes the PixelFormat into the RFB protocol format.
§Arguments
buf- A mutable reference to theBytesMutbuffer to write into.
Sourcepub fn from_bytes(buf: &mut BytesMut) -> Result<Self>
pub fn from_bytes(buf: &mut BytesMut) -> Result<Self>
Reads and deserializes a PixelFormat from a BytesMut buffer.
This function extracts pixel format information from the RFB protocol stream.
§Arguments
buf- A mutable reference to theBytesMutbuffer to read from.
§Returns
Ok(Self) containing the parsed PixelFormat.
§Errors
Returns Err(io::Error) if there are not enough bytes in the buffer
to read a complete PixelFormat.
Trait Implementations§
Source§impl Clone for PixelFormat
impl Clone for PixelFormat
Source§fn clone(&self) -> PixelFormat
fn clone(&self) -> PixelFormat
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more