Example #1
0
 private static extern bool StretchBlt( 
     IntPtr destDC,
     int dX,
     int dY,
     int dWidth,
     int dHeight,
     IntPtr sourceDC,
     int sX,
     int sY,
     int sWidth,
     int sHeight,
     RasterOperations ro);
Example #2
0
 private static extern bool BitBlt( 
     IntPtr targetDC,
     int targetX,
     int targetY,
     int targetWidth,
     int targetHeight,
     IntPtr sourceDC,
     int sourceStartX,
     int sourceStartY,
     RasterOperations ro);
Example #3
0
        private static Image CaptureScreenRegion( Point location, Size size, RasterOperations opcode )
        {
            Image myImage = new Bitmap( size.Width, size.Height );

            using ( Graphics g = Graphics.FromImage( myImage ) ) {

                IntPtr destDeviceContext = g.GetHdc();
                IntPtr srcDeviceContext = GetWindowDC( IntPtr.Zero ); // capture desktop

                // TODO: throw exception
                if ( !BitBlt( destDeviceContext, 0, 0, size.Width, size.Height, srcDeviceContext, location.X, location.Y,  opcode ) ) {
                    // throw exception
                }

                ReleaseDC( IntPtr.Zero, srcDeviceContext );
                g.ReleaseHdc( destDeviceContext );

            } // dispose the Graphics object

            return myImage;
        }
Example #4
0
 /// <summary>
 ///     Bitblt extension for the graphics object
 /// </summary>
 /// <param name="target">Graphics</param>
 /// <param name="sourceBitmap">Bitmap</param>
 /// <param name="source">Rectangle</param>
 /// <param name="destination">Point</param>
 /// <param name="rasterOperations">RasterOperations</param>
 public static void BitBlt(this Graphics target, Bitmap sourceBitmap, Rectangle source, NativePoint destination, RasterOperations rasterOperations)
 {
     using (var targetDc = target.GetSafeDeviceContext())
         using (var safeCompatibleDcHandle = CreateCompatibleDC(targetDc))
             using (var hBitmapHandle = new SafeHBitmapHandle(sourceBitmap.GetHbitmap()))
                 using (safeCompatibleDcHandle.SelectObject(hBitmapHandle))
                 {
                     BitBlt(targetDc, destination.X, destination.Y, source.Width, source.Height, safeCompatibleDcHandle, source.Left, source.Top, rasterOperations);
                 }
 }
Example #5
0
        public static Image StretchImage( Point p, Rectangle zoomRegion, Size desiredSize, RasterOperations opcode, bool captureLayeredWindows )
        {
            Image myImage = new Bitmap( desiredSize.Width, desiredSize.Height );

            using ( Graphics g = Graphics.FromImage( myImage ) ) {

                IntPtr destDeviceContext = g.GetHdc();
                IntPtr srcDeviceContext = GetWindowDC( IntPtr.Zero ); // capture desktop

                StretchBlt( destDeviceContext, 0, 0, desiredSize.Width, desiredSize.Height, srcDeviceContext, p.X, p.Y, zoomRegion.Width, zoomRegion.Height, opcode );
            //				StretchBlt( destDeviceContext, 0, 0, desiredSize.Width, desiredSize.Height, srcDeviceContext, p.X, p.Y, zoomRegion.Width, zoomRegion.Height, SRCCOPY | CAPTUREBLT );
                //Debug.WriteLine( "Error: " + Marshal.GetLastWin32Error() );

                ReleaseDC( IntPtr.Zero, srcDeviceContext );
                g.ReleaseHdc( destDeviceContext );

            } // dispose the Graphics object

            return myImage;
        }
Example #6
0
 public static extern bool BitBlt(SafeHandle hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, SafeHandle hdcSrc, int nXSrc, int nYSrc, RasterOperations rasterOperation);
Example #7
0
 public static extern bool StretchBlt(SafeHandle hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, SafeHandle hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, RasterOperations rasterOperation);
Example #8
0
        public static Image StretchImage(Point p, Rectangle zoomRegion, Size desiredSize, RasterOperations opcode, bool captureLayeredWindows)
        {
            Image myImage = new Bitmap(desiredSize.Width, desiredSize.Height);

            using (Graphics g = Graphics.FromImage(myImage)) {
                IntPtr destDeviceContext = g.GetHdc();
                IntPtr srcDeviceContext  = GetWindowDC(IntPtr.Zero);                  // capture desktop

                StretchBlt(destDeviceContext, 0, 0, desiredSize.Width, desiredSize.Height, srcDeviceContext, p.X, p.Y, zoomRegion.Width, zoomRegion.Height, opcode);
//				StretchBlt( destDeviceContext, 0, 0, desiredSize.Width, desiredSize.Height, srcDeviceContext, p.X, p.Y, zoomRegion.Width, zoomRegion.Height, SRCCOPY | CAPTUREBLT );
                //Debug.WriteLine( "Error: " + Marshal.GetLastWin32Error() );

                ReleaseDC(IntPtr.Zero, srcDeviceContext);
                g.ReleaseHdc(destDeviceContext);
            }             // dispose the Graphics object

            return(myImage);
        }
Example #9
0
 public static extern bool BitBlt(IntPtr hdcDest, int nxDest, int nyDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, RasterOperations dwRop);
Example #10
0
 public static extern bool BitBlt([In] IntPtr hdc, int nXDest, int nYDest, int nWidth, int nHeight,
     [In] IntPtr hdcSrc, int nXSrc, int nYSrc, RasterOperations dwRop);