21

I know I can capture the framebuffer in linux using something like cp /dev/fb0 ~/myimage and re-display that by coping back to the device like so cp ~/myimage /dev/fb0. What format is the framebuffer image data in? and how would I go about displaying a pre-made image (jpg, png) to the framebuffer? Can I convert to this format using imagemagick?

p.s. Im using a raspberry pi running raspbian.



Update 11-12-2012

I ended up using pygame to display images in my application. Not sure if this uses the frame-buffer to display the images. But it meets my needs quite well.

ndmweb
  • 391

6 Answers6

9

Have you tried Fbida?

fbida contains fbi, an image viewer for the framebuffer.

Link to fbi man page - http://manpages.ubuntu.com/manpages/lucid/man1/fbi.1.html

P.S - I am not sure whether it will work in Raspbian.

VenkatH
  • 636
3

it might help you, detailed manual http://hacklab.cz/2012/04/22/usefulness-linux-framebuffer-virtual-console I think it has all in one place about Linux Framebuffer

3

If you can install them, fbcat will create a ppm image, and fbgrab will create a png image.

2

What format is the framebuffer image data in?

The Linux kernel 4.2 documentation https://github.com/torvalds/linux/blob/v4.2/Documentation/fb/api.txt#45 says:

Pixels are stored in memory in hardware-dependent formats. Applications need to be aware of the pixel storage format in order to write image data to the frame buffer memory in the format expected by the hardware.

Formats are described by frame buffer types and visuals. Some visuals require additional information, which are stored in the variable screen information bits_per_pixel, grayscale, red, green, blue and transp fields.

Visuals describe how color information is encoded and assembled to create macropixels. Types describe how macropixels are stored in memory. The following types and visuals are supported.

A list of visuals and types follows, but the description is not enough for me to understand the exact formats immediately.

1

If you want to cp /dev/fb0 ~/myimage, the image should only contain the pixels information,and the order should be right (RGB, BGR, RGBA, ARGB...)

I want to do this too,but did not find a suitable tool, so I use python to help me pre-made the image. You can try this.

nKn
  • 5,832
zqb-all
  • 371
0

Look at /usr/include/linux/fb.h at structs like fb_var_screeninfo. There can be a variety of color depths and formats. I see 16 bits/pixel way too often, right now I have 32. Type fbset by itself and it will display the current settings. Which will almost certainly be one of the entries in /etc/fb.modes.

upstairs# fbset

mode "1920x1080"
    geometry 1920 1080 1920 1080 32
    timings 0 0 0 0 0 0 0
    rgba 8/16,8/8,8/0,8/24
endmode

Imagemagick might work if you can make it match exactly the mode you need. I'd probably write something in C, a dozen or so lines calling libjpeg or libpng can decompress an image into a memory array. Your bits/color etc. needs to match or you need to write something to convert it. Good experience.

Also rather than reading/writing /dev/fb0 as a file, open() it to get a file descriptor then mmap() it so you're working with a pointer to the memory. It's much faster at doing transfers, at least 10x.

But for putting images on the screen I just install qiv. Then hit F1 for help, but an x while displaying an image will write it semi-permanently to the root window if that's what you want. Or just set it as wallpaper in Desktop Preferences and it will come up every boot.