views:

40

answers:

2

Ok, so what I'm trying to do is have two imageboxes overlapping so that I can align the images in them (based on user input). The problem is I'm not sure if I can adjust the opacity of individual controls so I can only see the topmost control. Of course, I could do image processing and combine the two images into a single image (with the appropriate transparency settings) but doing that on each input operation would be somewhat expensive so I figured doing it on the UI thread would be a lot cheaper.

Any suggestions? Thank you in advance.

A: 

As @Kane says, wpf is probably better for this. Only the Form control supports Opacity as a property in winforms (see msdn), but you might be able to get away with it if you put your images in sub-forms (I'm really speculating here, haven't tried this.) and play with their opacity.

Good luck

Yoni H
+1  A: 

This isn't possible in WinForms, transparency effects don't work for overlapping controls. The best you could do is overlapping forms so you can use the Opacity and TransparencyKey properties.

A far more practical approach is to use one PictureBox in which you display a composite image. Such an image is easy to create with the ColorMatrix class. You'll find sample code in my answer in this thread.

Hans Passant