How can I overwrite a System.Drawing.Bitmap onto an existing GDI bitmap?
- by MusiGenesis
If I have a .Net Bitmap, I can create from it a GDI bitmap by calling the Bitmap's GetHbitmap() method.
Bitmap bmp = new Bitmap(100, 100);
IntPtr gdiBmp = bmp.GetHbitmap();
This works fine, but every time you call GetHbitmap, Windows has to allocate new memory for the object that gdiBmp references.
What I'd like to do - if possible - is write…