private Bitmap ScreenshotWindowGDI(IntPtr targetWindow, bool withOpaqueGlass) { Trace.WriteLine(string.Format("Creating screenshot of window {0}: '{1}'...", this.WindowClass, targetWindow), string.Format("Screenshot.ScreenshotWindowGDI [{0}]", System.Threading.Thread.CurrentThread.Name)); Bitmap ss = null; isMaximized = Helper.IsWindowMazimized(targetWindow); //var transparent = new Unmanaged.DWM_COLORIZATION_PARAMS(0x664b968a, 0x664b968a, 0x5, 0x2d, 0x32, 0x32, 0x0); //var opaque = new Unmanaged.DWM_COLORIZATION_PARAMS(0x664b968a, 0x664b968a, 0x28, 0x255, 0x32, 0x32, 0x1); CaptureRect = isMaximized ? this.TargetScreen.WorkingArea : TargetRect; //: BackingWindow.RectangleToScreen(ThumbRect); try { DWM.DWM_COLORIZATION_PARAMS OriginalColorization = Helper.GetColorization(); if (withOpaqueGlass && Helper.isCompositionEnabled && OriginalColorization.OpaqueBlend == 0) { DWM.DWM_COLORIZATION_PARAMS OpaqueColorization = OriginalColorization; OpaqueColorization.OpaqueBlend = 1; OpaqueColorization.ColorBalance = Math.Min(255, OpaqueColorization.ColorBalance * 8); OpaqueColorization.AfterglowBalance = (uint)(OpaqueColorization.AfterglowBalance / 4.5); DWM.DwmSetColorizationParameters(ref OpaqueColorization, 0); ss = Core.ScreenshotWindow(targetWindow); DWM.DwmSetColorizationParameters(ref OriginalColorization, 0); } else { ss = Core.ScreenshotWindow(targetWindow); } } catch (ArgumentException ae) { Trace.WriteLine("Argument Exception: " + ae.GetBaseException().Message); } catch (NullReferenceException nre) { Trace.WriteLine("Null Reference Exception: " + nre.GetBaseException().Message); } finally { ss = ss ?? Core.ScreenshotWindow(targetWindow); } Trace.WriteLine("Done.", string.Format("Screenshot.ScreenshotWindowGDI [{0}]", System.Threading.Thread.CurrentThread.Name)); var debug_path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), @"prosnap-debug"); if (System.IO.Directory.Exists(debug_path)) { ss.Save(System.IO.Path.Combine(debug_path, "raw.png"), System.Drawing.Imaging.ImageFormat.Png); } return(ss); }
public static DWM.DWM_COLORIZATION_PARAMS GetColorization() { DWM.DWM_COLORIZATION_PARAMS colorization = new DWM.DWM_COLORIZATION_PARAMS(); DWM.DwmGetColorizationParameters(out colorization); return(colorization); }
public static DWM.DWM_COLORIZATION_PARAMS GetColorization() { DWM.DWM_COLORIZATION_PARAMS colorization = new DWM.DWM_COLORIZATION_PARAMS(); DWM.DwmGetColorizationParameters(out colorization); return colorization; }