Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grabbing part of an image

Status
Not open for further replies.

spelltwister

Programmer
May 12, 2005
36
0
0
US
Hey,

I was wondering if there is a way to grab only part of an image to use for a background image in a picturebox.

Here's what I mean:

I have a picture box called map that has dimensions 2000x1300. This map has 170 different sub sections that i have all the regions for. What I'm trying to do is spawn 170 pictureboxes and set their backgrounds to the appropriate sections of the map. I'm assuming it has to do with the .clip, but I can't get it to work.

Here's what I tried:


Dim bit As Bitmap = New Bitmap(map.Image)
Dim gmap As Graphics = Graphics.FromImage(bit)
gmap.Clip = New Region(regionPath)
picboxes(k).image = bit

The error is that it uses the upper left corner of the map always. It does not use the section that i want it to which makes no sense that it can even use that corner cause it should be cropped off.

Maybe I just don't know what the .clip actually does... :-/

Thanks

Mike

Online multiplayer strategy games huh? Try, 1483online.com where the games are FREE and the community drives enhancements to the game. ;-D
 
Yep, it's a lot, but here's what happens:

When the form loads, it spawns about 170 pic boxes and adds a dragdrop handler. Then it cuts them out into the shape of a country. Then the background image is set as the section of the map I'm using (hence the post).

Once that's done, I spawn just over 200 more pic boxes and cut them into the shape of army markers. Then I add an onmousedown and dragstart or something like that to get them dragable. Then I set the background image to the appropriate marker type.

The reason for this is so that it records where I drag the piece and I can use that data to determine legal moves and upload to the server for turn processing.

If there's another way to to tell where the unit was drug, please let me know, though I'd still like to know how to solve the above problem :-D.

Thanks,

Mike

Online multiplayer strategy games huh? Try, 1483online.com where the games are FREE and the community drives enhancements to the game. ;-D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top