public static void RefreshDesktopSize() { var height = 0; var width = 0; foreach (var screen in Screen.AllScreens) { var w = screen.Bounds.X + screen.Bounds.Width; var h = screen.Bounds.Y + screen.Bounds.Height; if (height < h) { height = h; } if (width < w) { width = w; } } DesktopRectangle = new Rectangle(0, 0, width, height); if (_fullWidthFrame != null) { _fullWidthFrame.Destroy(); } else { _fullWidthFrame = new ReusableFrame(new Bitmap(width, height)); } }
public IBitmapFrame Get() { lock (_pool) { DestroyFreeFrames(); if (_pool.Count > 0) { return(_pool.Dequeue()); } var frame = new ReusableFrame(new Bitmap(Width, Height)); frame.Released += () => { lock (_pool) { _pool.Enqueue(frame); DestroyFreeFrames(); } }; _frames.Add(frame); Console.WriteLine($"New Frame Allocated: {_frames.Count - 1}"); return(frame); } }
public static void RefreshDesktopSize() { if (_fullWidthFrame != null) { _fullWidthFrame.Destroy(); } else { var rect = DesktopRectangle; _fullWidthFrame = new ReusableFrame(new Bitmap(rect.Width, rect.Height)); } }
public IBitmapFrame Get() { lock (_pool) { if (_pool.Count > 0) { return(_pool.Dequeue()); } var frame = new ReusableFrame(new Bitmap(Width, Height)); frame.Released += () => { lock (_pool) { _pool.Enqueue(frame); } }; _frames.Add(frame); return(frame); } }