コード例 #1
0
ファイル: DWM.cs プロジェクト: eservicepartner/espUrl
 public static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, out RECT lpRect, int size);
コード例 #2
0
ファイル: Structs.cs プロジェクト: Jusonex/ShareX
 public bool Equals(RECT Rectangle)
 {
     return Rectangle.Left == _Left && Rectangle.Top == _Top && Rectangle.Right == _Right && Rectangle.Bottom == _Bottom;
 }
コード例 #3
0
ファイル: Structs.cs プロジェクト: Jusonex/ShareX
 public RECT(RECT rectangle)
     : this(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom)
 {
 }
コード例 #4
0
ファイル: GDIplus.cs プロジェクト: Maximus325/ShareX
 private static extern int GdipBitmapApplyEffect(IntPtr bitmap, IntPtr effect, ref RECT rectOfInterest, bool useAuxData, IntPtr auxData, int auxDataSize);
コード例 #5
0
ファイル: GDIplus.cs プロジェクト: Maximus325/ShareX
        /// <summary>
        /// Use the GDI+ blur effect on the bitmap
        /// </summary>
        /// <param name="destinationBitmap">Bitmap to apply the effect to</param>
        /// <param name="area">Rectangle to apply the blur effect to</param>
        /// <param name="radius">0-255</param>
        /// <param name="expandEdges">bool true if the edges are expanded with the radius</param>
        /// <returns>false if there is no GDI+ available or an exception occured</returns>
        public static bool ApplyBlur(Bitmap destinationBitmap, Rectangle area, int radius, bool expandEdges)
        {
            if (!IsBlurPossible(radius))
            {
                return false;
            }
            IntPtr hBlurParams = IntPtr.Zero;
            IntPtr hEffect = IntPtr.Zero;

            try
            {
                // Create a BlurParams struct and set the values
                BlurParams blurParams = new BlurParams();
                blurParams.Radius = radius;
                blurParams.ExpandEdges = expandEdges;

                // Allocate space in unmanaged memory
                hBlurParams = Marshal.AllocHGlobal(Marshal.SizeOf(blurParams));
                // Copy the structure to the unmanaged memory
                Marshal.StructureToPtr(blurParams, hBlurParams, false);

                // Create the GDI+ BlurEffect, using the Guid
                int status = GdipCreateEffect(BlurEffectGuid, out hEffect);

                // Set the blurParams to the effect
                GdipSetEffectParameters(hEffect, hBlurParams, (uint)Marshal.SizeOf(blurParams));

                // Somewhere it said we can use destinationBitmap.GetHbitmap(), this doesn't work!!
                // Get the private nativeImage property from the Bitmap
                IntPtr hBitmap = GetNativeImage(destinationBitmap);

                // Create a RECT from the Rectangle
                RECT rec = new RECT(area);
                // Apply the effect to the bitmap in the specified area
                GdipBitmapApplyEffect(hBitmap, hEffect, ref rec, false, IntPtr.Zero, 0);

                // Everything worked, return true
                return true;
            }
            catch (Exception ex)
            {
                isBlurEnabled = false;
                LOG.Error("Problem using GdipBitmapApplyEffect: ", ex);
                return false;
            }
            finally
            {
                try
                {
                    if (hEffect != IntPtr.Zero)
                    {
                        // Delete the effect
                        GdipDeleteEffect(hEffect);
                    }
                    if (hBlurParams != IntPtr.Zero)
                    {
                        // Free the memory
                        Marshal.FreeHGlobal(hBlurParams);
                    }
                }
                catch (Exception ex)
                {
                    isBlurEnabled = false;
                    LOG.Error("Problem cleaning up ApplyBlur: ", ex);
                }
            }
        }
コード例 #6
0
ファイル: User32.cs プロジェクト: eservicepartner/espUrl
 public static extern int GetWindowRect(IntPtr hWnd, out RECT lpRect);
コード例 #7
0
ファイル: User32.cs プロジェクト: eservicepartner/espUrl
 public static extern int GetClientRect(IntPtr hWnd, out RECT lpRect);
コード例 #8
0
 public static extern int GetClipBox(IntPtr hdc, out RECT lprc);