Creates a new bitmap from a specific region of another bitmap : Bitmap « 2D Graphics « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# / C Sharp » 2D Graphics » Bitmap 




Creates a new bitmap from a specific region of another bitmap
       

using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;

namespace Isotope.ScreenCaptureLib
{
    public static class DrawingUtil
    {
        /// <summary>
        /// Creates a new bitmap from a specific region of another bitmap
        /// </summary>
        /// <param name="bmp_source"></param>
        /// <param name="region"></param>
        /// <returns></returns>
        public static Bitmap CopyBitmap(Bitmap bmp_source, Rectangle region)
        {
            var bmp_dest = new Bitmap(region.Width, region.Height);
            using (var g = Graphics.FromImage(bmp_dest))
            {
                g.DrawImage(bmp_source, 00, region, GraphicsUnit.Pixel);
            }
            return bmp_dest;
        }


    }
}

   
    
    
    
    
    
    
  














Related examples in the same category
1.Draw on an Bitmap
2.Resize the Bitmap using the lowest quality interpolation mode
3.Resize the Bitmap using the highest quality interpolation mode
4.Create Graphics object From Image
5.Bitmap.SetResolution
6.Bitmap property: Height, Physical Dimension, width, raw format and sizeBitmap property: Height, Physical Dimension, width, raw format and size
7.Create your own BitMapCreate your own BitMap
8.Draw shapes to the bitmap in memoryDraw shapes to the bitmap in memory
9.new Bitmap(bitmap, size)
10.Read Bitmap Size by using BinaryReader
11.Bitmap.HorizontalResolution
12.Use a color matrix to change the color properties of the image
13.Create a Bitmap image in memory and set its CompositingMode
14.Create a red color with an alpha component then draw a red circle to the bitmap in memory
15.Create a green color with an alpha component then draw a green rectangle to the bitmap in memory
16.write the pixel information to the console window
17.Double buffer with Bitmap
18.Draw an array of imagesDraw an array of images
19.Bit operation with PixelFormat.Alpha
20.PixelFormat.DontCare
21.Scale Bitmap By Percent
22.Draws Bitmap in a cell within a DataGridView
23.Bitmap Image Utils
24.Bitmap Operations
25.Make Bitmap from UIElement
26.Allows drawing fonts with borders and auto centers the font on a bitmap.
27.Create New Bitmap From Image
28.Simple Resize Bmp
29.Create Thumbnail
30.Calculate the RBG projection
31.Make Thumb
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.