PixelFormat

Struct PixelFormat 

Source
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: u8

Number of bits per pixel.

§depth: u8

Depth of the pixel in bits.

§big_endian_flag: u8

Flag indicating if the pixel data is big-endian (1) or little-endian (0).

§true_colour_flag: u8

Flag indicating if the pixel format is true-colour (1) or colormapped (0).

§red_max: u16

Maximum red color value.

§green_max: u16

Maximum green color value.

§blue_max: u16

Maximum blue color value.

§red_shift: u8

Number of shifts to apply to get the red color component.

§green_shift: u8

Number of shifts to apply to get the green color component.

§blue_shift: u8

Number of shifts to apply to get the blue color component.

Implementations§

Source§

impl PixelFormat

Source

pub fn rgba32() -> Self

Creates a standard 32-bit RGBA pixel format.

§Returns

A PixelFormat instance configured for 32-bit RGBA.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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 the BytesMut buffer to write into.
Source

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 the BytesMut buffer 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

Source§

fn clone(&self) -> PixelFormat

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PixelFormat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.