Michael Dutton Michael Dutton - 4 months ago 48
C++ Question

CBitmap from raw RGB values in std::vector<std::uint32_t> holding array

I have a bitmap in raw RGBA values in the following code from a library I found on the net. "svgren.

auto img = svgren::render(*dom, width, height); //uses 96 dpi by default
//At this point the 'width' and 'height' variables were filled with
//the actual width and height of the rendered image.
//Returned 'img' is a std::vector<std::uint32_t> holding array of RGBA values.

I need to know how to get this picture into a CBitmap so I can display it in an MFC Picture control. I can presize it and I know how to display a bitmap in the control. What I can't do is load the RGBA values into the bitmap. Any ideas please?

CBitmap Chb;
HBITMAP bmp = CreateBitmap(width, height, 1, 32, &*img.begin());
//PicControl.ModifyStyle(0xF, SS_BITMAP, SWP_NOSIZE);
mProjectorWindow.m_picControl.ModifyStyle(0xF, SS_BITMAP, SWP_NOSIZE);