Skip to main content

framebuffer_draw/
roxyloader_fb.rs

1use roxy_loader_api::framebuffer::{Framebuffer as RoxyloaderFb, PixelFormat as RoxyPixelFmt};
2
3use crate::{Framebuffer, PixelFormat};
4
5impl From<RoxyloaderFb> for Framebuffer {
6    fn from(value: RoxyloaderFb) -> Self {
7        Self {
8            ptr: value.ptr(),
9            size: value.size,
10            stride: value.stride,
11            pixel_format: value.pixel_format.into(),
12            width: value.width,
13            height: value.height,
14            bytes_per_pixel: value.bytes_per_pixel(),
15        }
16    }
17}
18
19impl From<RoxyPixelFmt> for PixelFormat {
20    fn from(value: RoxyPixelFmt) -> Self {
21        match value {
22            RoxyPixelFmt::Rgb => Self::Rgb,
23            RoxyPixelFmt::Bgr => Self::Bgr,
24            _ => panic!("Unsupported pixel format"),
25        }
26    }
27}