Hi all,
I'm trying to AND two bitmaps like this:
[DllImport("gdi32.dll")] public static extern int SetROP2(IntPtr hDC, int nDrawMode); const int SRCAND = 0x008800C6; // AND raster op. lock (g.Clip) { IntPtr pDC = g.GetHdc (); SetROP2 (pDC, SRCAND); g.DrawImageUnscaled (currentBitmap, bound.Location); g.ReleaseHdc (pDC); }
But I get an "Object is currently in use elsewhere" exception from the Draw statement. Moving the ReleaseHdc statement before the Draw statement runs, but doesn't use the specified raster op.
The LockBits approach is too slow, since it copies the whole bitmap twice, one of the bitmaps is huge, and this has to happen many times per second.
Any ideas how I can trick .NET into ANDing bitmaps?