1use std::time::Duration;
2
3use secgate::util::Handle;
4use twizzler_display::{Rect, WindowConfig};
5
6static IMG: &'static [u8] = include_bytes!("../img.png");
7
8fn main() {
9 let image = image::ImageReader::new(std::io::Cursor::new(IMG))
10 .with_guessed_format()
11 .unwrap()
12 .decode()
13 .unwrap();
14 let pixels = image.as_rgb8().unwrap();
15
16 let window = twizzler_display::WindowHandle::open(WindowConfig {
17 w: pixels.width(),
18 h: pixels.height(),
19 x: 0,
20 y: 0,
21 z: 0,
22 })
23 .unwrap();
24 window.window_buffer.update_buffer(|mut buf, _, _| {
25 for y in 0..pixels.height() {
26 for x in 0..pixels.width() {
27 let px = pixels[(x, y)];
28 let r = px[0] as u32;
29 let g = px[1] as u32;
30 let b = px[2] as u32;
31 let r = r as u32;
32 let g = g as u32;
33 let b = b as u32;
34 buf[(y * pixels.width() + x) as usize] = r << 16 | g << 8 | b << 0 | 0xff000000;
35 }
36 }
37 buf.damage(Rect::full());
38 });
39 window.window_buffer.flip();
40 std::thread::sleep(Duration::from_secs(3));
41}