I'm trying to create a bitmap using Win32 and Gdiplus. I don't want to load in a file I just want to create my own image by using Setpixel. I used this constructor:
void Bitmap(INT width, INT height, INT stride, PixelFormat format, BYTE *scan0);
But when I try to use Setpixel on my bitmap it does nothing even GetHeight returns 0.
m_pixelMap = new BYTE[m_renderSpaceWidth*m_renderSpaceHeight * 3];
Gdiplus::Bitmap img(m_renderSpaceWidth, m_renderSpaceHeight, 24 * m_renderSpaceWidth, PixelFormat24bppRGB, m_pixelMap);
std::cout << "H: " << img.GetHeight() << std::endl;
What am I doing wrong?
stride
is meant to be the number of bytes from one row to the next, not the number of bits. Additionally, bitmap rows must be DWORD-aligned; depending on the width for a 24 bpp bitmap you may need padding bytes for each row to satisfy this requirement. – Jonathan Potter