LorgonJortle Posted November 28, 2009 Posted November 28, 2009 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 Quote
Leaders snarfblam Posted November 28, 2009 Leaders Posted November 28, 2009 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. Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.