Results 1 to 4 of 4

Thread: Interesting image box question

  1. #1

    Thread Starter
    Lively Member Optic's Avatar
    Join Date
    Mar 2001
    Location
    I'm everywhere and nowhere, I'm inside your computer and inside your mind. You can't escape me for I am vision.
    Posts
    117

    Interesting image box question

    I have an array of image boxes that contain gifs with transparencies. The image boxes are layered ontop of each other. Is there any way that when I click on the layers of image boxes that I can get the box where the location I click on is not transparent. An example I have a shirt as one image box and a logo on top of it as another. Both image boxes are the same size. If I click on them normally I would always get the logo. But I want to be able to click on the shirt where the logo image is transparent and get the shirt image. Is this possible?

  2. #2
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Sorry, there's a way of doing it but it would be a bit complicated... you would have to loop trough all the images in order (starting from the one on top), and for each one of them check if the pixel where the user clicked is the same color as the background... and if it isn't, that's your image

    What do you want it for? I could help you but it's gonna be a bit hard for such a tiny effect (maybe you could use a picturebox only the size of the logo?).
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  3. #3

    Thread Starter
    Lively Member Optic's Avatar
    Join Date
    Mar 2001
    Location
    I'm everywhere and nowhere, I'm inside your computer and inside your mind. You can't escape me for I am vision.
    Posts
    117
    Thanks for the help. I figured it would have to be something long and hard. The reason why all the boxes need to be the same size is for lining things up. I would have to keep track of what is in every box so I know where the imagebox should be placed. Otherwise the image is already in the right place and all the picture boxes go to the same location. Also the software I'm creating is going to be customizeable so the user can add their own graphics into the program so it would be hard to keep track of locations and such. I'll have to figure out a different approach.

  4. #4
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Oh well... I just remembered that imageboxes don't have a Point function or a DC or anything... so there's no way of getting the color of a point in the image. You'll have to keep a seperate, hidden copy of each image in a picturebox (not imagebox).

    After all it wouldn't be that hard... You know the position of the mouse click, you'll just have to loop trough all the images and see if the color at that position is grey (or whatever). Speed is not very important so you can use VB's Point, like this (this is just pseudo-code to give you an idea of how to do it )

    (on the image's MouseDown event)

    For i = 0 to Number of Pictureboxes - 1
    If Picturebox(i).Point(X, Y) <> RGB(128,128,128) Then
    MsgBox "You clicked picture " & i
    Exit For
    End If
    Next i

    Just remember that the pictureboxes must be in reverse order - the first in the control array is the one at the top, and the last is the one at the bottom.
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

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