bootloader icon indicating copy to clipboard operation
bootloader copied to clipboard

Framebuffer Color

Open asensio-project opened this issue 3 years ago • 7 comments

Hello,

I'm writing my kernel using the last version of this crate. I'm including support for the framebuffer for writing text on the screen, I based the driver on the logger.rs of the bootloader, and it works, but when I try to change the colour of the text via modifying the let color = match self.info.pixel_format { PixelFormat::RGB => [intensity, intensity, intensity / 2, 0], PixelFormat::BGR => [255 / 2, 0, 0, 0], PixelFormat::U8 => [if intensity > 200 { 0xf } else { 0 }, 0, 0, 0], }; I get a big line with the colour that I put, but no the text. qemu

asensio-project avatar Aug 07 '22 11:08 asensio-project

PixelFormat::BGR => [255 / 2, 0, 0, 0],

This line should probably use intensity too.

bjorn3 avatar Aug 07 '22 14:08 bjorn3

How can I use it?

asensio-project avatar Aug 07 '22 15:08 asensio-project

If you want it to be the same color as the PixelFormat::RGB => [intensity, intensity, intensity / 2, 0], case, you have to write PixelFormat::BGR => [intensity / 2, intensity, intensity, 0] I think.

bjorn3 avatar Aug 07 '22 15:08 bjorn3

Ok, but If I want it in blue or white instead yellow?

asensio-project avatar Aug 07 '22 16:08 asensio-project

Then you use other values.

bjorn3 avatar Aug 07 '22 19:08 bjorn3

Thanks,

Now, I use this system for changing the colour: I only need enable or disable the colour from the slice.

  • For enabling: intensity
  • For disabling: intensity / 2

For example for using the pink colour in a BGR screen: [intensity, intensity / 2, intensity, 0]

But I don't know the utility of the last element, and how to change the background colour.

asensio-project avatar Aug 07 '22 22:08 asensio-project

How can I change the background colour?

asensio-project avatar Aug 08 '22 11:08 asensio-project

I'v extracted some code from bootloader/src/binary/logger.rs (thanks for @bjorn3 mention this example in other issue) and wrap them like as blog_os vga_text_mode interface, including the background/foreground color setting features.

@asensio-project You can find find these code at https://github.com/AmberCrafter/rustos/tree/main/src/library/renderer and a little documents https://github.com/AmberCrafter/rustos/tree/main/documents/FrameBuffer

Unfortunately, the font pixel based on noto-sans-mono-bitmap is encoding in u8 (0-255), that mean the colors are gradually changing. This property make the font looks ambiguous with non-black backgound color (see below), and i'v no ideal how to overcome this problem. (Maybe using other font's bitmap crate)

image

image


Thanks for @phil-opp and many contributors provide these exciting projects!!

AmberCrafter avatar Aug 21 '22 17:08 AmberCrafter

Thank you all. It's answered.

asensio-project avatar Aug 25 '22 22:08 asensio-project