Beispiel #1
0
 public static void AlphaBlendImage(Graphics g, Image image, int x, int y, int alpha)
 {
     int width = image.Width;
     int weight = image.Height;
     using (Graphics imageG = Graphics.FromImage(image))
     {
         IntPtr hdcDst = g.GetHdc();
         IntPtr hdcSrc = imageG.GetHdc();
         GdiEx.BlendFunction blendFunction = new GdiEx.BlendFunction();
         blendFunction.BlendOp = (byte)GdiEx.BlendOperation.AC_SRC_OVER;
         blendFunction.BlendFlags = (byte)GdiEx.BlendFlags.Zero;
         blendFunction.SourceConstantAlpha = (byte)alpha;
         blendFunction.AlphaFormat = (byte)0;
         AlphaBlend(hdcDst, x, y, width, weight, hdcSrc, 0, 0, width, weight, blendFunction);
         imageG.ReleaseHdc(hdcSrc);
         g.ReleaseHdc(hdcDst);
     }
 }
Beispiel #2
0
        public static void AlphaBlendImage(Graphics g, Image image, int x, int y, int alpha)
        {
            int width  = image.Width;
            int weight = image.Height;

            using (Graphics imageG = Graphics.FromImage(image))
            {
                IntPtr hdcDst = g.GetHdc();
                IntPtr hdcSrc = imageG.GetHdc();
                GdiEx.BlendFunction blendFunction = new GdiEx.BlendFunction();
                blendFunction.BlendOp             = (byte)GdiEx.BlendOperation.AC_SRC_OVER;
                blendFunction.BlendFlags          = (byte)GdiEx.BlendFlags.Zero;
                blendFunction.SourceConstantAlpha = (byte)alpha;
                blendFunction.AlphaFormat         = (byte)0;
                AlphaBlend(hdcDst, x, y, width, weight, hdcSrc, 0, 0, width, weight, blendFunction);
                imageG.ReleaseHdc(hdcSrc);
                g.ReleaseHdc(hdcDst);
            }
        }