framebuffer-draw 0.1.0

Draw pixels on a raw framebuffer
Documentation
  • Coverage
  • 66.67%
    10 out of 15 items documented1 out of 6 items with examples
  • Size
  • Source code size: 13.68 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 361.29 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • RoxyOS/framebuffer-draw
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • NikoPit

framebuffer-draw

Draw pixels on a raw framebuffer.

This crate provides a small no_std API for writing individual pixels into a framebuffer-backed memory region. It is designed for low-level graphics code where you already have a pointer, dimensions, stride, and pixel format.

Usage

This example will draw a straight line on the framebuffer:

use framebuffer_draw::{Color, Framebuffer, PixelFormat};

let framebuffer = Framebuffer {
    // Pointer to the first byte of the framebuffer memory.
    ptr: todo!(),
    // The total framebuffer size in bytes.
    size: todo!(),
    // The number of pixels in each row.
    stride: todo!(),
    // The pixel format used when writing pixel data.
    pixel_format: PixelFormat::Rgb,
    // Width of the framebuffer in pixels.
    width: todo!(),
    // Height of the framebuffer in pixels.
    height: todo!(),
    // The number of bytes used by each pixel.
    bytes_per_pixel: todo!(),
};

// Draws a straight line.
let limit = core::cmp::min(framebuffer.width, framebuffer.height);
for i in 0..limit {
    framebuffer.draw_pixel(i, i, Color::rgb(255, 0, 0));
}

If you are using roxy-laoder, you can convert its framebuffer type directly to framebuffer-draw's framebuffer type:

use framebuffer_draw::Framebuffer;
use roxy_loader_api::framebuffer::Framebuffer as RoxyloaderFramebuffer;

let roxyloader_fb: RoxyloaderFramebuffer = /* ... */;
let fb: Framebuffer = roxyloader_fb.into();