@@ -49,6 +49,9 @@ public enum BackgroundType
4949 public bool DoResize ;
5050 public int ResizeX ;
5151 public int ResizeY ;
52+ public bool DoCanvas ;
53+ public int CanvasX ;
54+ public int CanvasY ;
5255 public bool DisableShadow ;
5356 public IntPtr WindowHandle ;
5457 public bool SaveActiveDark ;
@@ -66,14 +69,18 @@ public ScreenshotTask(IntPtr window, bool clipboard, string file,
6669 bool mouse , bool clearType , bool shadow ,
6770 bool saveActiveDark , bool saveActiveLight , bool saveInactiveDark ,
6871 bool saveInactiveLight , bool saveMask , bool saveActiveTransparent ,
69- bool saveInactiveTransparent )
72+ bool saveInactiveTransparent ,
73+ bool canvas , int canvasX , int canvasY )
7074 {
7175 WindowHandle = window ;
7276 ClipboardNotDisk = clipboard ;
7377 DiskSaveDirectory = file ;
7478 DoResize = resize ;
7579 ResizeX = resizeX ;
7680 ResizeY = resizeY ;
81+ DoCanvas = canvas ;
82+ CanvasX = canvasX ;
83+ CanvasY = canvasY ;
7784 Background = backType ;
7885 BackgroundColor = backColor ;
7986 CheckerboardSize = checkerSize ;
@@ -629,7 +636,7 @@ private static unsafe Bitmap[] CaptureCompositeScreenshot(ref ScreenshotTask dat
629636
630637 if ( data . CaptureMouse )
631638 DrawCursorToBitmap ( transparentImage , new Point ( rct . Left , rct . Top ) ) ;
632- Bitmap [ ] final = CropEmptyEdges ( new [ ] { transparentImage , transparentInactiveImage , transparentWhiteImage , transparentWhiteInactiveImage , transparentMaskImage , transparentTransparentImage , transparentTransparentInactiveImage } , Color . FromArgb ( 0 , 0 , 0 , 0 ) ) ;
639+ Bitmap [ ] final = CropEmptyEdges ( new [ ] { transparentImage , transparentInactiveImage , transparentWhiteImage , transparentWhiteInactiveImage , transparentMaskImage , transparentTransparentImage , transparentTransparentInactiveImage } , Color . FromArgb ( 0 , 0 , 0 , 0 ) , ref data ) ;
633640
634641
635642 //TODO: checkerboard support
@@ -724,7 +731,7 @@ private static unsafe Bitmap GenerateChecker(int s)
724731 return b1 ;
725732 }
726733
727- private static unsafe Bitmap [ ] CropEmptyEdges ( Bitmap [ ] b1 , Color trimColor )
734+ private static unsafe Bitmap [ ] CropEmptyEdges ( Bitmap [ ] b1 , Color trimColor , ref ScreenshotTask data )
728735 {
729736 if ( b1 == null )
730737 return null ;
@@ -836,6 +843,16 @@ private static unsafe Bitmap[] CropEmptyEdges(Bitmap[] b1, Color trimColor)
836843 if ( b1 [ i ] == null )
837844 continue ;
838845 final [ i ] = b1 [ i ] . Clone ( new Rectangle ( left , top , rightSize , bottomSize ) , b1 [ i ] . PixelFormat ) ;
846+ if ( data . DoCanvas )
847+ {
848+ Bitmap temp = new Bitmap ( data . CanvasX , data . CanvasY ) ;
849+ using ( Graphics grD = Graphics . FromImage ( temp ) )
850+ {
851+ grD . DrawImage ( final [ i ] , new Rectangle ( 0 , 0 , final [ i ] . Width , final [ i ] . Height ) , new Rectangle ( 0 , 0 , final [ i ] . Width , final [ i ] . Height ) , GraphicsUnit . Pixel ) ;
852+ }
853+ final [ i ] . Dispose ( ) ;
854+ final [ i ] = temp ;
855+ }
839856 b1 [ i ] . Dispose ( ) ;
840857 }
841858
0 commit comments