C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How to clip a portion of image in a picturebox and display it in another picturebox


Posted Date: 10 May 2008    Resource Type: Code Snippets    Category: Graphics
Author: Balamurali BalajiMember Level: Diamond    
Rating: Points: 10



The following code clips a portion of image of size width=100 and height=100. It displays a clipped portion in another picture box. To run this code, place two picture boxes in a form and set the image for the first picturebox.



Bitmap ReqdBmp = new Bitmap(100, 100);
Graphics Gra = pictureBox1.CreateGraphics();
Graphics g2 = pictureBox2.CreateGraphics();
g2.DrawImage(pictureBox1.Image, new Rectangle(0, 0, ReqdBmp.Width, ReqdBmp.Height), new Rectangle(100, 100, ReqdBmp.Width, ReqdBmp.Height), GraphicsUnit.Pixel);






Responses

Author: Neeraj Saluja    12 May 2008Member Level: Gold   Points : 2
The code is not appearing completely. It should be

Bitmap ReqdBmp = new Bitmap(100, 100);
Graphics Gra = pictureBox1.CreateGraphics();
Graphics g2 = pictureBox2.CreateGraphics();
g2.DrawImage(pictureBox1.Image, new Rectangle(0, 0, ReqdBmp.Width, ReqdBmp.Height), new Rectangle(100, 100, ReqdBmp.Width, ReqdBmp.Height), GraphicsUnit.Pixel);







Author: Balamurali Balaji    12 May 2008Member Level: Diamond   Points : 2
Thank you.


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Show Clock
Previous Resource: How to display the form in Pentagonal shape
Return to Discussion Resource Index
Post New Resource
Category: Graphics


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use