public static Bitmap Copy(Point pt1,Point pt2,Bitmap bmpOrg)
{
int PixelSize = 3;
int width = pt2.X-pt1.X;
int height = pt2.Y-pt1.Y;
Bitmap bmpCpy = new Bitmap(width,height);
BitmapData bDataOrg = bmpOrg.LockBits(new
Rectangle(0,0,bmpOrg.Width,bmpOrg.Height),
ImageLockMode.ReadWrite,bmpOrg.PixelFormat);
BitmapData bDataCpy = bmpCpy.LockBits(new
Rectangle(0,0,bmpCpy.Width,bmpCpy.Height),
ImageLockMode.ReadWrite,bmpOrg.PixelFormat);
unsafe
{
byte *pCpy = (byte*)bDataCpy.Scan0;
byte *pOrg = (byte*)bDataOrg.Scan0;
int nOffset = bDataOrg.Stride - bmpOrg.Width*PixelSize;
int nWidth = bmpOrg.Width * PixelSize;
for (int i=0;i<bmpOrg.Height;i++)
{
for (int j=0;j<bmpOrg.Width;j++)
{
if(j>=pt1.X && j<pt2.X && i>=pt1.Y && i<pt2.Y)
{
pCpy[0] = pOrg[0];
pCpy[1] = pOrg[1];
pCpy[2] = pOrg[2];
pCpy+=3;
}
pOrg+=3;;
}
pOrg+=nOffset;
}
}
bmpOrg.UnlockBits(bDataOrg);
bmpCpy.UnlockBits(bDataCpy);
return bmpCpy;
}
Bob Powell [MVP] - 29 May 2004 22:43 GMT
Is this a question or a statement of fact?

Signature
Bob Powell [MVP]
Visual C#, System.Drawing
Image transition effects, automatic persistent configuration and
design time mouse operations all in April's issue of Well Formed
http://www.bobpowell.net/wellformed.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm
The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://royo.is-a-geek.com/siteFeeder/GetFeed.aspx?FeedId=41
> public static Bitmap Copy(Point pt1,Point pt2,Bitmap bmpOrg)
> {
[quoted text clipped - 45 lines]
> return bmpCpy;
> }