I've been trying to do this for a couple of days now. Google had no answers anywhere.
The problem is that I need to pass an Image type as a parameter in TextureBrush. I only have an HBITMAP. I've looked at quite a few possibilities and no success.
Here is what I have:
// change my HBITMAP to GDI+ BITMAP
Bitmap bmpTestingIt(hbmBGTiles, NULL);
Graphics g(buffer.getBufferDC());
//Image image(L"C:/Users/Owner/Pictures/testbmp.bmp"); // This works but not what I need
//Image image(bmpTestingIt); // No
//Image image((Image)bmpTestingIt); // No
Rect rct(0, 0, bmpTestingIt.GetWidth(), bmpTestingIt.GetHeight());
TextureBrush brush(&image, rct);
g.FillRectangle(&brush, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
Any help is greatly appreciated.
Thanks.
Since Bitmap
inherits from Image
, I'm unclear why you need any of the commented lines. Instead just use &bmpTestingIt
instead of &image
. Just make sure you're constructing the Bitmap
correctly (which should come down to passing the HPALETTE
if it's not a device-independent bitmap; if it is a DIB, you're fine).