Get/SetDIbits of BITMAP pixel

If I load an HBITMAP from file, how can I get and set the pixel data?
I can see some links on how to get the data, but I can't find out how to set the data or make a new bitmap object from that.
Something like this:
1
2
3
4
5
6
7
8
9
10
11
12
      BITMAPINFO bmi;
      std::fill(reinterpret_cast<std::uint8_t *>(&bmi), reinterpret_cast<std::uint8_t *>(&bmi) + sizeof(bmi), 0);
      bmi.bmiHeader.biSize = sizeof(bmi);
      bmi.bmiHeader.biWidth = extent.x;
      bmi.bmiHeader.biHeight = extent.y;
      bmi.bmiHeader.biPlanes = 1;
      bmi.bmiHeader.biBitCount = 32;
      bmi.bmiHeader.biCompression = BI_RGB;

      const HDC cur_hdc = ...;

      const HBITMAP hb = CreateDIBSection(cur_hdc, &bmi, DIB_RGB_COLORS, &result, 0, 0);
result is the buffer to fill with rgb colors.
Topic archived. No new replies allowed.