Пример #1
0
        private static void CopyGraphics(Graphics gxSrc, Graphics gxDest, int width, int height)
        {
            IntPtr destDc = gxDest.GetHdc();
            IntPtr srcDc  = gxSrc.GetHdc();

            PlatformAPIs.BitBlt(destDc, 0, 0, width, height, srcDc, 0, 0, TernaryRasterOperations.SRCCOPY);
            gxSrc.ReleaseHdc(srcDc);
            gxDest.ReleaseHdc(destDc);
        }
Пример #2
0
 public static void DrawAlpha(Graphics gx, Bitmap image, byte transp, int x, int y)
 {
     using (Graphics gxSrc = Graphics.FromImage(image))
     {
         IntPtr        hdcDst        = gx.GetHdc();
         IntPtr        hdcSrc        = gxSrc.GetHdc();
         BlendFunction blendFunction = new BlendFunction();
         blendFunction.BlendOp             = (byte)BlendOperation.AC_SRC_OVER; // Only supported blend operation
         blendFunction.BlendFlags          = (byte)BlendFlags.Zero;            // Documentation says put 0 here
         blendFunction.SourceConstantAlpha = transp;                           // Constant alpha factor
         blendFunction.AlphaFormat         = (byte)0;                          // Don't look for per pixel alpha
         PlatformAPIs.AlphaBlend(hdcDst, x, y, image.Width, image.Height, hdcSrc, 0, 0, image.Width, image.Height, blendFunction);
         gx.ReleaseHdc(hdcDst);                                                // Required cleanup to GetHdc()
         gxSrc.ReleaseHdc(hdcSrc);                                             // Required cleanup to GetHdc()
     }
 }