Page 1 of 1

How to create a DIB Bitmap from a Byte Array?

Posted: Thu Dec 06, 2018 2:54 pm
by Parduz
I have a byte array containing the "raw" data (i mean: the pixels) of a 4-bit-per-pixels grayscale image. I receive this data via RS232 from an old device and i can't change this. But I need to draw this image on a wxPanel.

I have an old code made with C++Builder 2006 which initialize a DIB bmp with a 16 color palette, and then it memcpy the array in it each time i receive a new image, convert to screen bpp while scaling it x3 and finally show it on the screen.

I need to do this with wxWidgets (and make it working in both Windows and Linux) but i'm struggling to find how to do the same.

How could i show that array of bytes as an image using wxWidgets 3.0.4?



Thanks.

Re: How to create a DIB Bitmap from a Byte Array?

Posted: Thu Dec 06, 2018 3:01 pm
by doublemax
Create an empty wxBitmap with the correct size and use raw bitmap access to write the RGB data into it:
https://docs.wxwidgets.org/trunk/classw ... _data.html

(You have to convert it to 24bit RGB).