Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Howdy there!

I've a picturebox that holds a rather large image. I was wondering if it was possible, with the right code, to save a portion of the image to a .bmp file. For example, (This is for my map editor) they load a large bitmap of their map, and want it cut into tiles of 32x32. Is this possible in VB.NET, and if so, may I have a point in the right direction?

 

Note: I'm rather new to VB.NET.

 

Thanks for any help,

 

LJ

  • Leaders
Posted

Well, first of all, let's take the picture box out of the equation. What you're really after is a part of the image it contains, rather than the picture box itself (which has a border and could be obscured by another window), right?

 

First you would want to create a new Bitmap object, then create a Graphics object for that Bitmap. The Graphics object permits you to draw to the new Bitmap. Get the image that is hosted in the picture box and use Graphics.DrawImage to draw a portion of the original image to the new Bitmap. Now you can save the Bitmap. Make sure to dispose of the Bitmap and Grapdhics when you no longer need them.

 

I recommend using MSDN or Google to look up the documentation on these classes for the specifics.

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...