Results 1 to 5 of 5

Thread: PaintPicture

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214

    PaintPicture

    I have a tile map and a bunch of tiles, each with its own image box, meaning I have like 20 pictures. Now I want to have all the tiles in one picture and choose which tiles from that picture to draw. Hope this makes sense any help would be useful

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    So...what exactly do you need help with?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214
    I have a tile map and it draws the pictures like this, see how i have two pictures, one for each tile.
    Code:
    Case Is = "A"
                        Picture1.PaintPicture imgshort.Picture, (X + 3) * 25, (Y + 3) * 25
                    Case Is = "B"
                        Picture1.PaintPicture imgtall.Picture, (X + 3) * 25, (Y + 3) * 25
    well i want it to do this with just one picture that contains both tiles. how would I do this? make sense yet?

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by jeb2022
    well i want it to do this with just one picture that contains both tiles. how would I do this? make sense yet?
    Yeah, I gotcha. My suggestion would be to use BitBlt. It allows you to specify where on the tile picture you want to take the image from.

    It's declaration is:

    VB Code:
    1. Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, _
    2.   ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, _
    3.   ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long

    You can just throw that in the top of your form, or remove the keyword 'Private' and put it in a module.

    Then to use it, just replace the PaintPictures with:

    VB Code:
    1. Case "A"
    2.     BitBlt Picture1.hdc, (x + 3) * 25, (y + 3) * 25, 25, 25, _
    3.         imgTiles.hdc, 0, 0, vbSrcCopy

    Where Picture1.hdc is where you're painting to, the next two parameters are the x and y of where you're painting to, the two 25s are the width and height, respectively. imgTiles.hdc is the picture with all the tiles, and the two 0s are the x and y of where that tile starts on the tile picture.

    So if it's the first tile, it'll be 0, 0. The second tile, it'll probably be 24, 0, if the tile are going across horizontally.

    Do you follow?

    Edit: Added BitBlt declaration.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214
    I get ya. Kewl thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width