splitting bitmaps

  • Thread starter Thread starter Kevin A.
  • Start date Start date
K

Kevin A.

Hi all,

I'm trying to make a little game in VB.NET that uses sprites (bitmaps)
with a fixed size, currently 32x32 pixels.
Now I was thinking: when I want to include objects in my game
(buildings or so) that consist of multiple sprites, I would have to
divide that object into individual sprites and draw them separately in
Paint. But this is too hard to do.
For example, if I wanted a building with a size of 96x64 pixels
(or 3x2 measured in sprites), I would have to draw 6 separate images
of 32x32 in Paint.
Or: I could draw the entire image of 96x64 in one piece, and include
a function in my application that divides this large image into 6 images
of 32x32.
The problem is: how can I do this? How can I copy a part of an
image (the large image) into a smaller image (the sprite)?

Please help. Thanks in advance.



Kevin
 
Hello Kevin,

there is an overload of Graphics.DrawImage that takes the source rectangle
and the destination rectangle as arguments. So you could call DrawImage
repeatedly with squares of 32x32 at a time to draw from your source image
to a target device (or bitmap).

HTH
Antoine


This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.


--------------------
 
Back
Top