Beispiel #1
0
        public bool UpdateLayered(IntPtr hdcDst, ref Point pptDst, ref Size psize, IntPtr hdcSrc, ref Point pprSrc, int crKey)
        {
            BlendFunction f = BlendFunction.Default;

            return(NativeMethods.UpdateLayeredWindow(Handle, hdcDst, ref pptDst, ref psize, hdcSrc, ref pprSrc, crKey, ref f,
                                                     (int)NativeMethods.UpdateLayeredWindowFlags.Alpha));
        }
        public void AlphaBlendImage(ImageWithDeviceContext sourceImage, Rectangle srcRectangle, Rectangle destRectangle, byte opacity)
        {
            BlendFunction f = BlendFunction.Default;

            f.SourceConstantAlpha = opacity;
            NativeMethods.AlphaBlend(Dc, destRectangle.X, destRectangle.Y, destRectangle.Width, destRectangle.Height, sourceImage.Dc, srcRectangle.X, srcRectangle.Y, srcRectangle.Width, srcRectangle.Height,
                                     f);
        }
Beispiel #3
0
 public static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref Point pptDst, ref Size psize, IntPtr hdcSrc, ref Point pprSrc, int crKey, ref BlendFunction pblend, int dwFlags);
Beispiel #4
0
        internal static void StretchImageWithOutMargin(IDeviceContext destImage, int destX, int destY, int destWidth, int destHeight, ImageWithDeviceContext srcImage, int srcY, int srcWidth, int srcHeight, Padding stretchExcludeMargin, byte opacity)
        {
            BlendFunction blend = BlendFunction.Default;

            blend.SourceConstantAlpha = opacity;
            IntPtr destDc = destImage.GetHdc();

            if (stretchExcludeMargin.Left > 0)
            {
                NativeMethods.AlphaBlend(destDc, destX, destY + stretchExcludeMargin.Top, stretchExcludeMargin.Left, destHeight - (stretchExcludeMargin.Top + stretchExcludeMargin.Bottom), srcImage.Dc, 0, srcY + stretchExcludeMargin.Top, stretchExcludeMargin.Left, srcHeight - (stretchExcludeMargin.Top + stretchExcludeMargin.Bottom),
                                         blend);
            }

            if (stretchExcludeMargin.Right > 0)
            {
                NativeMethods.AlphaBlend(destDc, destX + (destWidth - stretchExcludeMargin.Right), destY + stretchExcludeMargin.Top, stretchExcludeMargin.Right, destHeight - (stretchExcludeMargin.Bottom + stretchExcludeMargin.Top), srcImage.Dc, srcWidth - stretchExcludeMargin.Right, srcY + stretchExcludeMargin.Top, stretchExcludeMargin.Right, srcHeight - (stretchExcludeMargin.Bottom + stretchExcludeMargin.Top),
                                         blend);
            }

            if (stretchExcludeMargin.Top > 0)
            {
                NativeMethods.AlphaBlend(destDc, destX + stretchExcludeMargin.Left, destY, destWidth - (stretchExcludeMargin.Left + stretchExcludeMargin.Right), stretchExcludeMargin.Top, srcImage.Dc, stretchExcludeMargin.Left, srcY, srcWidth - (stretchExcludeMargin.Left + stretchExcludeMargin.Right), stretchExcludeMargin.Top,
                                         blend);
                if (stretchExcludeMargin.Left > 0)
                {
                    NativeMethods.AlphaBlend(destDc, destX, destY, stretchExcludeMargin.Left, stretchExcludeMargin.Top, srcImage.Dc, 0, srcY, stretchExcludeMargin.Left, stretchExcludeMargin.Top,
                                             blend);
                }

                if (stretchExcludeMargin.Right > 0)
                {
                    NativeMethods.AlphaBlend(destDc, (destWidth - stretchExcludeMargin.Right) + destX, destY, stretchExcludeMargin.Right, stretchExcludeMargin.Top, srcImage.Dc, srcWidth - stretchExcludeMargin.Right, srcY, stretchExcludeMargin.Right, stretchExcludeMargin.Top,
                                             blend);
                }
            }

            if (stretchExcludeMargin.Bottom > 0)
            {
//                WinAPI.AlphaBlend(DestDC, DestX, DestY + (DestHeight - stretchExcludeMargin.Bottom), DestWidth, stretchExcludeMargin.Bottom, srcImage.DC, 0, SrcY + (srcHeight - stretchExcludeMargin.Bottom), srcWidth, stretchExcludeMargin.Bottom,
//                    Blend);

                NativeMethods.AlphaBlend(destDc, destX + stretchExcludeMargin.Left, destY + (destHeight - stretchExcludeMargin.Bottom),
                                         destWidth - (stretchExcludeMargin.Left + stretchExcludeMargin.Right),
                                         stretchExcludeMargin.Top,
                                         srcImage.Dc,
                                         stretchExcludeMargin.Left,
                                         srcY + (srcHeight - stretchExcludeMargin.Bottom),
                                         srcWidth - (stretchExcludeMargin.Left + stretchExcludeMargin.Right),
                                         stretchExcludeMargin.Bottom,
                                         blend);

                if (stretchExcludeMargin.Left > 0)
                {
                    NativeMethods.AlphaBlend(destDc, destX, destY + (destHeight - stretchExcludeMargin.Bottom), stretchExcludeMargin.Left, stretchExcludeMargin.Bottom, srcImage.Dc, 0, srcY + (srcHeight - stretchExcludeMargin.Bottom), stretchExcludeMargin.Left, stretchExcludeMargin.Bottom,
                                             blend);
                }

                if (stretchExcludeMargin.Right > 0)
                {
                    NativeMethods.AlphaBlend(destDc, (destWidth - stretchExcludeMargin.Right) + destX, destY + (destHeight - stretchExcludeMargin.Bottom), stretchExcludeMargin.Right, stretchExcludeMargin.Bottom, srcImage.Dc, srcWidth - stretchExcludeMargin.Right, srcY + (srcHeight - stretchExcludeMargin.Bottom), stretchExcludeMargin.Right, stretchExcludeMargin.Bottom,
                                             blend);
                }
            }

            NativeMethods.AlphaBlend(destDc, destX + stretchExcludeMargin.Left, destY + stretchExcludeMargin.Top, destWidth - (stretchExcludeMargin.Left + stretchExcludeMargin.Right), destHeight - (stretchExcludeMargin.Top + stretchExcludeMargin.Bottom), srcImage.Dc, stretchExcludeMargin.Left, srcY + stretchExcludeMargin.Top, srcWidth - (stretchExcludeMargin.Left + stretchExcludeMargin.Right), srcHeight - (stretchExcludeMargin.Top + stretchExcludeMargin.Bottom),
                                     blend);
            destImage.ReleaseHdc();
        }
Beispiel #5
0
 public static extern bool AlphaBlend(IntPtr hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest,
                                      int nHeightDest, IntPtr hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc,
                                      BlendFunction blendFunction);