public static void DrawImage(ref Graphics grDest, ref Bitmap grSrcBitmap) { grSrc = Graphics.FromImage(grSrcBitmap); hdcDest = grDest.GetHdc(); hdcSrc = grSrc.GetHdc(); hBitmap = grSrcBitmap.GetHbitmap(); hOldObject = SelectObject(hdcSrc, hBitmap); BitBlt(hdcDest, 0, 0, grSrcBitmap.Width, grSrcBitmap.Height, hdcSrc, 0, 0, 0x00CC0020U); if (hOldObject != IntPtr.Zero) SelectObject(hdcSrc, hOldObject); if (hBitmap != IntPtr.Zero) DeleteObject(hBitmap); if (hdcDest != IntPtr.Zero) grDest.ReleaseHdc(hdcDest); if (hdcSrc != IntPtr.Zero) grSrc.ReleaseHdc(hdcSrc); }
public unsafe static void DrawImageHighSpeed() { SetDIBits(hdcDest, hBitmap, 0, (uint)h, data_ptr, ref info, DIB_RGB_COLORS); BitBlt(hdcDest, 0, 0, w , h , hdcSrc, 0, 0, 0x00CC0020U); }
public unsafe static void initHighSpeed(ref Graphics _grDest, int width, int height, uint[] data) { w = width; h = height; _Bitmap = new Bitmap(width, height); grSrc = Graphics.FromImage(_Bitmap); grDest = _grDest; hdcDest = grDest.GetHdc(); hdcSrc = grSrc.GetHdc(); hBitmap = _Bitmap.GetHbitmap(); hOldObject = SelectObject(hdcSrc, hBitmap); info = new BITMAPINFO(); info.bmiHeader = new BITMAPINFOHEADER(); info.bmiHeader.biSize = (uint)Marshal.SizeOf(info.bmiHeader); info.bmiHeader.biWidth = w; info.bmiHeader.biHeight = h; info.bmiHeader.biPlanes = 1; info.bmiHeader.biBitCount = 32; info.bmiHeader.biCompression = BitmapCompressionMode.BI_RGB; info.bmiHeader.biSizeImage = (uint)(w * h * 4); fixed (uint* dptr = data) { data_ptr = (IntPtr)dptr;} } public unsafe static void freeHighSpeed() { if (hOldObject != IntPtr.Zero) SelectObject(hdcSrc, hOldObject); if (hBitmap != IntPtr.Zero) DeleteObject(hBitmap); if (hdcDest != IntPtr.Zero) grDest.ReleaseHdc(hdcDest); if (hdcSrc != IntPtr.Zero) grSrc.ReleaseHdc(hdcSrc); try { _Bitmap.Dispose(); } catch { } }
public unsafe static void DrawImageHighSpeedtoDevice() { SetDIBitsToDevice(hdcDest, 0, 0, (uint)w, (uint)h, 0, 0, 0, (uint)h, data_ptr, ref info, DIB_RGB_COLORS); }