/// <summary>
 /// Bitblt extension for the graphics object
 /// </summary>
 /// <param name="target"></param>
 /// <param name="source"></param>
 public static void BitBlt(this Graphics target, Bitmap sourceBitmap, Rectangle source, Point destination, CopyPixelOperation rop)
 {
     using (SafeDeviceContextHandle targetDC = target.GetSafeDeviceContext()) {
         using (SafeCompatibleDCHandle safeCompatibleDCHandle = CreateCompatibleDC(targetDC)) {
             using (SafeHBitmapHandle hBitmapHandle = new SafeHBitmapHandle(sourceBitmap.GetHbitmap())) {
                 using (safeCompatibleDCHandle.SelectObject(hBitmapHandle)) {
                     BitBlt(targetDC, destination.X, destination.Y, source.Width, source.Height, safeCompatibleDCHandle, source.Left, source.Top, rop);
                 }
             }
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// StretchBlt extension for the graphics object
 /// Doesn't work?
 /// </summary>
 /// <param name="target"></param>
 /// <param name="source"></param>
 public static void StretchBlt(this Graphics target, Bitmap sourceBitmap, Rectangle source, Rectangle destination)
 {
     using (SafeDeviceContextHandle targetDC = target.getSafeDeviceContext()) {
         using (SafeCompatibleDCHandle safeCompatibleDCHandle = CreateCompatibleDC(targetDC)) {
             using (SafeHBitmapHandle hBitmapHandle = new SafeHBitmapHandle(sourceBitmap.GetHbitmap())) {
                 using (SafeSelectObjectHandle selectObject = safeCompatibleDCHandle.SelectObject(hBitmapHandle)) {
                     StretchBlt(targetDC, destination.X, destination.Y, destination.Width, destination.Height, safeCompatibleDCHandle, source.Left, source.Top, source.Width, source.Height, CopyPixelOperation.SourceCopy);
                 }
             }
         }
     }
 }
 /// <summary>
 /// StretchBlt extension for the graphics object
 /// Doesn't work?
 /// </summary>
 /// <param name="target"></param>
 /// <param name="source"></param>
 public static void StretchBlt(this Graphics target, Bitmap sourceBitmap, Rectangle source, Rectangle destination)
 {
     using (SafeDeviceContextHandle targetDC = target.getSafeDeviceContext())
     {
         using (SafeCompatibleDCHandle safeCompatibleDCHandle = CreateCompatibleDC(targetDC))
         {
             using (SafeHBitmapHandle hBitmapHandle = new SafeHBitmapHandle(sourceBitmap.GetHbitmap()))
             {
                 using (SafeSelectObjectHandle selectObject = safeCompatibleDCHandle.SelectObject(hBitmapHandle))
                 {
                     StretchBlt(targetDC, destination.X, destination.Y, destination.Width, destination.Height, safeCompatibleDCHandle, source.Left, source.Top, source.Width, source.Height, CopyPixelOperation.SourceCopy);
                 }
             }
         }
     }
 }
Beispiel #4
0
 /// <summary>
 /// Bitblt extension for the graphics object
 /// </summary>
 /// <param name="target"></param>
 /// <param name="source"></param>
 public static void BitBlt(this Graphics target, Bitmap sourceBitmap, Rectangle source, Point destination, CopyPixelOperation rop)
 {
     using (SafeDeviceContextHandle targetDC = target.GetSafeDeviceContext())
     {
         using (SafeCompatibleDCHandle safeCompatibleDCHandle = CreateCompatibleDC(targetDC))
         {
             using (SafeHBitmapHandle hBitmapHandle = new SafeHBitmapHandle(sourceBitmap.GetHbitmap()))
             {
                 using (safeCompatibleDCHandle.SelectObject(hBitmapHandle))
                 {
                     BitBlt(targetDC, destination.X, destination.Y, source.Width, source.Height, safeCompatibleDCHandle, source.Left, source.Top, rop);
                 }
             }
         }
     }
 }