luckie
asked on
2 and a half D and Graphics Layers
Hi,
first of all, let me introduce 2 and a half D, it is a technique that
draws 3D graphics on 2D spaces. I'm using VB and ActiveX controls as
sprites. However,
on the form bitmap, there are a lot of components fixed in in the bitmap,
such as the megalift (do not take it seriously if you don't know what that
is) , rackings and beams (in a warehouse literally). How do I make those
objects go in front or behind of the sprites? I know that involves graphics
layers. How do i manipulate layers in VB in order to achieve this effect? (Z-order won't work because you can't bring the 'megalift' to front without bringing the whole bitmap so)Thanks
Jacky
first of all, let me introduce 2 and a half D, it is a technique that
draws 3D graphics on 2D spaces. I'm using VB and ActiveX controls as
sprites. However,
on the form bitmap, there are a lot of components fixed in in the bitmap,
such as the megalift (do not take it seriously if you don't know what that
is) , rackings and beams (in a warehouse literally). How do I make those
objects go in front or behind of the sprites? I know that involves graphics
layers. How do i manipulate layers in VB in order to achieve this effect? (Z-order won't work because you can't bring the 'megalift' to front without bringing the whole bitmap so)Thanks
Jacky
ASKER
Not that kind... I mean there are some components embedded in the background images, how do I make sprites go behind those components, such as the beam (it's like Z-ordering) or something like that
Thanks
Jack
Thanks
Jack
That's what I meant about some "foreground" elements. Anything that the sprites are going to go behind has to be in a separate layer from the "background".
How you do the layering is up to you. You can either do it using images with transparent backgrounds (though something tells me I've tried this and it doesn't really work), or you bitblt the different layers to a picture control such that you bitblt first the background, then your sprite, then your foreground element.
This sort of animation is classical Disney style.
How you do the layering is up to you. You can either do it using images with transparent backgrounds (though something tells me I've tried this and it doesn't really work), or you bitblt the different layers to a picture control such that you bitblt first the background, then your sprite, then your foreground element.
This sort of animation is classical Disney style.
ASKER
I understand now, but the 'foreground' elements are actually part of the background bitmap? How do I resolve that?
Thanks
Jack
Thanks
Jack
With a drawing package like Paintbrush or Photoshop I'm afraid. What you will want to do is copy the background picture, color over everything in the picture that is not part of the foreground element in one specific color (the specific color doesn't matter as long as that color isn't found in the foreground element. I usually pick something obvious like bright pink. Then, in the transparent bitblt routine. You pick the color to make transparent, and that will be your pink color. When the image gets drawn on the display bitmap, only the non-transparent color bits will get drawn.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great.Thanks
Other than that, the approach that is most often used is custom "bitblt"ing - which is to say, copying selected portions of different pictures into the display picture. The bitblt Windows API can allow you to create a transparency mask so that you would bitblt your sprite on top of a background picture, and then you could also bitblt some foreground element on top of the sprite.
You can get a pretty cool example of the transparent bitblt code from Karl Peterson's website:
http://www.mvps.org/vb/
Download the CustomBlt.zip sample