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
精彩评论