Posts: 11
Joined: Wed Jul 23, 2014 12:52 pm

how can i render an image from byte array

Mon Sep 22, 2014 6:26 am

i want to render a .BMP image from byte array (contain data of .bmp image).
i heard about OpenGL but not know how to use it with raspberry pi.

can anyone suggest me some tutorial or basic example to learn Image rendering using OpenGL + raspberry pi.

thank you

Posts: 3
Joined: Mon Aug 13, 2012 2:07 pm

Re: how can i render an image from byte array

Tue Sep 23, 2014 10:40 am

OpenGL for 2D image rendering is not good idea for starter.
OpenGL-ES does not support Image-formats , it supports RAW data in RGB/BGR/RGBA/ARGB format.

I suggest using Higher level Library like Python, OpenCV, Magik, c++/Qt, WxWidgets etc.


User avatar
Posts: 80
Joined: Mon Dec 26, 2011 9:19 pm
Location: S.W. UK
Contact: Website

Re: how can i render an image from byte array

Fri Sep 26, 2014 12:40 pm

The BMP file format has a bitmap header and a bitmap info header then if you set those up correctly then you fwrite out your RGB bytes in the selected format and write out the termination characters to end the file. In Windows you can do this using some API calls. In linux / Raspberry PI land you can either do it by hand by following the format in the documention from Microsoft or by using a library. Or you can pick an easier format to use and use an external app like Gimp or Photoshop etc to convert from your format to BMP. I would suggest looking at the portable pixel map PPM format for example which I believe is easier to write by hand.

Return to “C/C++”