Reputation: 211
I have 3 pictureBoxs each one have transparent image, like this:
To make the picture 2 and picture 3 transparent for picture 1 , I wrote this code:
pictureBox2.Parent = pictureBox1;
pictureBox3.Parent = pictureBox1;
Now, my problem: How can I make picture 2 transparent for picture 3?
Upvotes: 3
Views: 568
Reputation: 941465
There's a limit to how well this will work, you are past that limit when you start to nest images. You'll then see that a PictureBox is only transparent against its Parent, parts of the composite image where other PBs contribute pixels won't be visible. You'll see the Parent's background instead.
You'll need to switch to a single PictureBox and write code. Implement its Paint event handler and call e.Graphics.DrawImage() to draw the images. Layering is now no longer a problem, paint is always transparent against its background. Also the way that WPF implements transparency.
Upvotes: 4