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: usizeZoom level as a percentage (100 = 1:1). Range 25..=400.
offset_x: isizePan offset (pixels in image-space).
offset_y: isize§surface_id: Option<u32>Compositor surface ID (set when wired to the desktop).
width: usizeWindow dimensions.
height: usize§toolbar_height: usizeHeight of the toolbar in pixels.
Implementations§
Source§impl ImageViewer
impl ImageViewer
Sourcepub fn load_ppm(data: &[u8]) -> Result<Image, &'static str>
pub fn load_ppm(data: &[u8]) -> Result<Image, &'static str>
Load a PPM image (P3 ASCII or P6 binary).
Sourcepub fn load_bmp(data: &[u8]) -> Result<Image, &'static str>
pub fn load_bmp(data: &[u8]) -> Result<Image, &'static str>
Load a BMP image (24-bit or 32-bit uncompressed).
Sourcepub fn load_tga(data: &[u8]) -> Result<Image, &'static str>
pub fn load_tga(data: &[u8]) -> Result<Image, &'static str>
Load a TGA image via the video decoder, converting to BGRA u32 pixels.
Sourcepub fn load_qoi(data: &[u8]) -> Result<Image, &'static str>
pub fn load_qoi(data: &[u8]) -> Result<Image, &'static str>
Load a QOI image via the video decoder, converting to BGRA u32 pixels.
Sourcepub fn load_file(&mut self, filename: &str, data: &[u8])
pub fn load_file(&mut self, filename: &str, data: &[u8])
Load an image file from raw byte data, auto-detecting the format.
Sourcepub fn handle_key(&mut self, key: u8) -> ImageViewerAction
pub fn handle_key(&mut self, key: u8) -> ImageViewerAction
Handle a keyboard event and return the resulting action.
Sourcepub fn render_to_buffer(
&self,
buffer: &mut [u32],
buf_width: usize,
buf_height: usize,
)
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
impl ImageViewer
Sourcepub fn render_to_u8_buffer(
&self,
buf: &mut [u8],
buf_width: usize,
buf_height: usize,
)
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.