Beispiel #1
0
        internal static void AlphaBlendImage(IntPtr hdcDst, Image image, Rectangle bounds, int alpha, bool srcAlpha)
        {
            int width  = image.Width;
            int weight = image.Height;

            using (Graphics imageG = Graphics.FromImage(image))
            {
                IntPtr hdcSrc = imageG.GetHdc();
                GdiExt.BlendFunction blendFunction = new GdiExt.BlendFunction();
                blendFunction.BlendOp             = (byte)GdiExt.BlendOperation.AC_SRC_OVER;
                blendFunction.BlendFlags          = (byte)GdiExt.BlendFlags.Zero;
                blendFunction.SourceConstantAlpha = (byte)alpha;
                blendFunction.AlphaFormat         = srcAlpha ? (byte)1 : (byte)0;
                AlphaBlend(hdcDst, bounds.X, bounds.Y, bounds.Width, bounds.Height, hdcSrc, 0, 0, width, weight, blendFunction);
                imageG.ReleaseHdc(hdcSrc);
            }
        }
Beispiel #2
0
 internal static void AlphaBlendImage(IntPtr hdcDst, Image image, Rectangle bounds, int alpha, bool srcAlpha)
 {
     int width = image.Width;
     int weight = image.Height;
     using (Graphics imageG = Graphics.FromImage(image))
     {
         IntPtr hdcSrc = imageG.GetHdc();
         GdiExt.BlendFunction blendFunction = new GdiExt.BlendFunction();
         blendFunction.BlendOp = (byte)GdiExt.BlendOperation.AC_SRC_OVER;
         blendFunction.BlendFlags = (byte)GdiExt.BlendFlags.Zero;
         blendFunction.SourceConstantAlpha = (byte)alpha;
         blendFunction.AlphaFormat = srcAlpha ? (byte)1 : (byte)0;
         AlphaBlend(hdcDst, bounds.X, bounds.Y, bounds.Width, bounds.Height, hdcSrc, 0, 0, width, weight, blendFunction);
         imageG.ReleaseHdc(hdcSrc);
     }
 }