开发者

Better way to overlap (superimpose) images in WPF?

开发者 https://www.devze.com 2023-02-09 04:00 出处:网络
I had a requirement to overlay two images in WPF for a project. On searching around, I finally ended up using DrawingImage class using DrawingGroup as suggest开发者_Python百科ed here: Overlay two bitm

I had a requirement to overlay two images in WPF for a project. On searching around, I finally ended up using DrawingImage class using DrawingGroup as suggest开发者_Python百科ed here: Overlay two bitmap images in WPF

var group = new DrawingGroup();
group.Children.Add(new ImageDrawing(new BitmapImage(new Uri(@"...\Some.jpg", UriKind.Absolute)), new Rect(0, 0, ??, ??)));
group.Children.Add(new ImageDrawing(new BitmapImage(new Uri(@"...\Some.png", UriKind.Absolute)), new Rect(0, 0, ??, ??)));

MyImage.Source = new DrawingImage(group);

But I got stuckup as I am unable to convert it back to BitmapImage for further manipulations.

Any other ideas on overlapping images in WPF?


I was able to accomplish my requirement using DrawingVisual class. For more info, refer here: Drawing Bitmaps – DrawingImage and DrawingVisual

0

精彩评论

暂无评论...
验证码 换一张
取 消