Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2010 > BOOK: Visual Basic 2010 Programmer's Reference
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Visual Basic 2010 Programmer's Reference
This is the forum to discuss the Wrox book Visual Basic 2010 Programmer's Reference by Rod Stephens; ISBN: 9780470499832
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Visual Basic 2010 Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 23rd, 2011, 05:07 AM
Authorized User
Points: 193, Level: 3
Points: 193, Level: 3 Points: 193, Level: 3 Points: 193, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Nov 2011
Posts: 31
Thanks: 6
Thanked 0 Times in 0 Posts
Smile Cloning section of a bitmap image


I am really new to programming in Visual Basic 2010. I would like to know how to write the code so I can automatically clone a specified rectangular section of a given bitmap image and place the new image in a specified picture box.

For example, I have an image called kite.bmp and I want to clone a section consisting of the pixels 0 to 100 on the X axis and 0 to 100 on the Y axis and I want to place the new image in pictureBox1.

In my particular application this process would be done thousands of times per image, cloning a different specified section each time. Although I could use an imaging editing program like PhotoShop to do this on an individual basis, it would clearly be impractical to manually run this process so many times. That is why I need to write the code to run the process automatically. In affect would be breaking down the entire Bitmap image, one section at a time, into individual pictures.

If I can understand how to do one, I think I can write the code for them all. I have been stumped by this for days and it seems that it should be fairly straight forward. I anyone can help me I would greatly appreciate it.

Last edited by Gary108; November 23rd, 2011 at 11:10 AM.. Reason: Mispelled words and to make it easier to understand.
Reply With Quote
  #2 (permalink)  
Old November 23rd, 2011, 11:07 AM
Rod Stephens's Avatar
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts

This isn't too bad. Here are the steps.
  1. Create a new Bitmap that's the right size to hold the piece you are copying.
  2. Create a Graphics object to work with the new Bitmap.
  3. Use the Graphics object's DrawImage method to draw the part of the image you want into the new Bitmap.
See this example:
Copy part of an image into a new PictureBox in Visual Basic .NET

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
Reply With Quote
The Following User Says Thank You to Rod Stephens For This Useful Post:
Gary108 (November 23rd, 2011)

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
invalid cross thread acces exception on creating a new bitmap image abhishekkashyap27 C# 4.0 aka C# 2010 General Discussion 11 August 6th, 2011 01:15 PM
New Image (Bitmap) instance or not? jacob C# 2005 0 April 4th, 2006 04:12 AM
Cloning a XmlTextReader billy_bob_the_3rd XML 0 March 28th, 2006 06:42 PM
Placing Image in Header Section Of Crystal Report B.V.Madhav BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 0 May 9th, 2005 02:44 AM
Read bitmap image? RichardRose C# 3 October 9th, 2004 11:45 PM

All times are GMT -4. The time now is 07:23 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.