How to convert a 16-bit RGB frame buffer to a view format?

I am working with another user's code on a device that can put an image in /dev/fb/0 and appear on the video output or send it over the network to a client application.

I do not have access to the old source for the client application, but I know the following about the data:

  • 720x480
  • 16 bit
  • RGB (I'm not sure if it is 5.5.5 or 5.6.5)
  • RAW (no headers)
  • cat -able to /dev/fb/0
  • 675kb

How can I transfer this header or convert it to JPEG, BMP or RAW format, which I could view in a desktop application?

Ultimately, I want it to be jpeg and viewable in a browser, but everything I see with my own eyes will now work.

Success

(see comments below)

 ffmpeg \ -vcodec rawvideo \ -f rawvideo \ -pix_fmt rgb565 \ -s 720x480 \ -i in-buffer.raw \ \ -f image2 \ -vcodec mjpeg \ out-buffer.jpg 

Unsuccessful attempts

Shows an image three times wide with almost no color and shrinks vertically:

 rawtoppm -rgb -interpixel 720 480 fb.raw > fb.ppm 

Shows an image, but with stripes and vertically squashed and poor color:

 rawtoppm -rgb -interrow 720 480 fb.raw > fb.ppm 

Same as above

 convert -depth 16 -size 720x480 frame_buffer.rgb fb.jpeg 
+4
source share
2 answers

rgb to ppm: just to taste!

supported by https://github.com/coolaj86/image-examples

 #include <stdio.h> int main(int argc, char* argv[]) { FILE* infile; // fb.raw FILE* outfile; // fb.ppm unsigned char red, green, blue; // 8-bits each unsigned short pixel; // 16-bits per pixel unsigned int maxval; // max color val unsigned short width, height; size_t i; infile = fopen("./fb.raw", "r"); outfile = fopen("./fb.ppm", "wb"); width = 720; height = 480; maxval = 255; // P3 - PPM "plain" header fprintf(outfile, "P3\n#created with rgb2ppm\n%d %d\n%d\n", width, height, maxval); for (i = 0; i < width * height; i += 1) { fread(&pixel, sizeof(unsigned short), 1, infile); red = (unsigned short)((pixel & 0xF800) >> 11); // 5 green = (unsigned short)((pixel & 0x07E0) >> 5); // 6 blue = (unsigned short)(pixel & 0x001F); // 5 // Increase intensity red = red << 3; green = green << 2; blue = blue << 3; // P6 binary //fwrite(&(red | green | blue), 1, sizeof(unsigned short), outfile); // P3 "plain" fprintf(outfile, "%d %d %d\n", red, green, blue); } } 
+5
source

I am developing an embedded system with the RGB 5: 6: 5 format, and sometimes I needed to write raw framebuffer data and convert it to a visible image. For experimentation, I wrote some C code to convert raw binary values ​​to link text . The format is dumb, but easy to read, so I found it convenient for hacking. Then I used Imagemagick display to view and convert to convert to JPG. (If I remember correctly, the convert will accept raw binary images, but it is assumed that you know all the parameters of the image, i.e. 5: 6: 5 compared to 5: 5: 5).

I can send a sample C code to convert 5: 6: 5 to 8: 8: 8 RGB, if necessary.

+2
source

All Articles