⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

ImageViewer

Struct ImageViewer 

Source
pub struct ImageViewer {
    pub state: ImageViewerState,
    pub image: Option<Image>,
    pub filename: String,
    pub zoom_level: usize,
    pub offset_x: isize,
    pub offset_y: isize,
    pub surface_id: Option<u32>,
    pub width: usize,
    pub height: usize,
    pub toolbar_height: usize,
}
Expand description

Image viewer application state.

Fields§

§state: ImageViewerState§image: Option<Image>§filename: String§zoom_level: usize

Zoom level as a percentage (100 = 1:1). Range 25..=400.

§offset_x: isize

Pan offset (pixels in image-space).

§offset_y: isize§surface_id: Option<u32>

Compositor surface ID (set when wired to the desktop).

§width: usize

Window dimensions.

§height: usize§toolbar_height: usize

Height of the toolbar in pixels.

Implementations§

Source§

impl ImageViewer

Source

pub fn new() -> Self

Create a new, empty image viewer.

Source

pub fn load_ppm(data: &[u8]) -> Result<Image, &'static str>

Load a PPM image (P3 ASCII or P6 binary).

Source

pub fn load_bmp(data: &[u8]) -> Result<Image, &'static str>

Load a BMP image (24-bit or 32-bit uncompressed).

Source

pub fn load_tga(data: &[u8]) -> Result<Image, &'static str>

Load a TGA image via the video decoder, converting to BGRA u32 pixels.

Source

pub fn load_qoi(data: &[u8]) -> Result<Image, &'static str>

Load a QOI image via the video decoder, converting to BGRA u32 pixels.

Source

pub fn load_file(&mut self, filename: &str, data: &[u8])

Load an image file from raw byte data, auto-detecting the format.

Source

pub fn zoom_in(&mut self)

Increase zoom by one step.

Source

pub fn zoom_out(&mut self)

Decrease zoom by one step.

Source

pub fn zoom_fit(&mut self)

Fit image to viewer area.

Source

pub fn handle_key(&mut self, key: u8) -> ImageViewerAction

Handle a keyboard event and return the resulting action.

Source

pub fn render_to_buffer( &self, buffer: &mut [u32], buf_width: usize, buf_height: usize, )

Render the image viewer into a u32 BGRA pixel buffer.

buffer must be at least buf_width * buf_height elements.

Source§

impl ImageViewer

Source

pub fn render_to_u8_buffer( &self, buf: &mut [u8], buf_width: usize, buf_height: usize, )

Render the image viewer into a u8 BGRA pixel buffer.

Delegates to render_to_buffer (u32), then converts to u8 bytes.

Trait Implementations§

Source§

impl Default for ImageViewer

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Freeze for ImageViewer

§

impl RefUnwindSafe for ImageViewer

§

impl Send for ImageViewer

§

impl Sync for ImageViewer

§

impl Unpin for ImageViewer

§

impl UnwindSafe for ImageViewer

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.