Results 1 to 6 of 6

Thread: [Sort of Resolved] Picture Splitting

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    540

    [Sort of Resolved] Picture Splitting

    Say if i wanted to split a picture up into an array, every 32x32 pixels is a index of the array.

    So like i could say i want index 1 to go here... then index 2 to go here and so on. I have no idea how to do this and no idea where to start.

    For an assignment i have to create a basic 2D game and i decided that this would be the best way to do so (since loading an array of picture boxes uses up alot of memory). If there is a better way then please tell me.

    I need to have mouse control (so the mouse knows which square in the map it's clicking on, not tile from the picture file).
    The ability to have the map move (so you can explore)
    Keyboard inputs.

    The rest i will figure out myself, but if you generous you will tell me them .

    I really only can't figure out how to split the pictures up!

    Thanks.
    Last edited by Slyke; Jun 25th, 2006 at 06:58 PM.

  2. #2
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Picture Splitting

    I don't really understand what your asking - do you just want to impose an abitary grid on a picture? Something like this perhaps:
    VB Code:
    1. Private Const lPixels As Long = 32
    2.  
    3. Private Sub Form_Load()
    4.     Picture1.ScaleMode = vbPixels
    5. End Sub
    6.  
    7. Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    8.     Dim lGridX As Long, lGridY As Long
    9.     lGridX = (X \ lPixels) + 1
    10.     lGridY = (Y \ lPixels) + 1
    11.     Debug.Print "X: " & lGridX, "Y: " & lGridY
    12. End Sub

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    540

    Re: Picture Splitting

    Yes, that will give me which square the mouse is over.

    You solved one of my problems so i thank you!

    But my problem was...

    How can i load a picture into these squares?

    Like say i have a bitmap & the first 32x32 pixels are blue (for water)
    the 2nd 32x32 pixels (which starts at pixel 33 i believe) is green, for grass.

    and so on for different stuff.

    Then i want to be able to use that to say index 1 goes into square 1 2 3 & 4 & index 2 goes into 5 6 7 & 8. so the first line of the map will have 4 blue squares and 5 6 7 & 8 will have green squares (or what ever else i place in the picture).

    Also say if i wanted grass on square 7, and then i wanted a picture of a shield ontop of it, how can i do this without have a white gap behind the shield (because it's over the top of the grass) or drawing a shield for each different land type?

    Also knowing how to scroll is something that i know i will have troubles with, but one step at a time, lol.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    540

    Re: Picture Splitting

    Any ideas? Any pages? You don't have to type it for me... a nice tutorial would be helpful (related to VB) or some ideas! I checked out the search but didn't provide anything specific.
    Last edited by Slyke; Jun 25th, 2006 at 08:05 AM.

  5. #5
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Picture Splitting

    i think you can do what you want with the BitBlt and TransparentBlt APIs - but I don't know anything about game programming. Check out our Games and Graphics Programming forum - there should be lots of information there + you'll get more specialised responses

  6. #6
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Picture Splitting

    I'm not sure. Give it a try:

    Using GetDIBits (or GetPixel -slow) API, you can get color of each individual pixel.
    So, make an UDT that can store 32x32 pixels.
    Create an UDT array.
    Inside 2 for loops, get pixel colors and save them in that UDT array.

    http://www.vb-helper.com/howto_getdibits.html
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


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