Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hallo,

I like to overlay to images, but one has to be transperant in some parts. So the idea is to see the most of the time image1 and at some parts image2.
I thought that I can solve this with a DrawingGroup with
- member1 = image1 and
- member2 = another DrawingGroup which includes image2 and the OpacityMask with is simular to image2 so that just the parts which are not 0 in image 2 are getting visible.

A little code:

DrawingGroup test = new DrawingGroup();
test.Children.Add(new ImageDrawing(source, new Rect(0, 0, width, height))); //image1

DrawingGroup test2 = new DrawingGroup();
test2.Children.Add(new ImageDrawing(source2, new Rect(0, 0, width, height))); //image2
test2.OpacityMask = new ImageBrush() { ImageSource = source2};

test.Children.Add(test2);

MyImage.Source = new DrawingImage(test);

The result is that just image 2 can be seen and image 1 in the background is totally overdrawn.

Hope you understand the problem I also would like to have as a result a posible imagesource because I like to send it dirket to image.source.

Thanks for your help.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900