|
-
Aug 9th, 2002, 11:20 AM
#1
Thread Starter
Lively Member
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?
-
Aug 10th, 2002, 07:02 PM
#2
Frenzied Member
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?).
-
Aug 13th, 2002, 10:58 AM
#3
Thread Starter
Lively Member
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.
-
Aug 13th, 2002, 02:25 PM
#4
Frenzied Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|