In GDI+ we can create a direct bitmap like so: https://stackoverflow.com/a/34801225/16141581
We allocate an array of pixels, create a new bitmap and pass during the instanciation of the bitmap a pointer to the adress of the first element in the array.
We then can proceed to change the elements of the array, such that the changes are applied to the bitmap automatically.
How exactly can I reproduce this with HBITMAP in win32?
I am using the CreateBitmap
function:
HBITMAP hBitmap;
uint32_t arr[240 * 240];
//WndProc function
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_CREATE:
{
// source: https://stackoverflow.com/a/56229028/16141581
std::fill(arr, arr + sizeof(arr) / sizeof(*arr), RGB(255, 0, 0));
hBitmap = CreateBitmap(240, 240, 1, 32, (void*)arr);
return 0;
}
}
But changing elements of that particular array doesnt change the bitmap. Why not?