Exemplo n.º 1
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()
     }
 }
Exemplo n.º 2
0
 extern public static Int32 AlphaBlend(IntPtr hdcDest, Int32 xDest, Int32 yDest, Int32 cxDest, Int32 cyDest, IntPtr hdcSrc, Int32 xSrc, Int32 ySrc, Int32 cxSrc, Int32 cySrc, BlendFunction blendFunction);