Overlay two bitmap images in WPF

百般思念 提交于 2019-12-06 10:11:26

问题


I need to overlay two images (say, JPEG and PNG with transparency).

Input: - JPEG image - PNG image

Output: - JPEG image with PNG applied.

What is the best approach to do that?

Thank you in advance for the replies and hints!

Cheers


回答1:


You can use a DrawingGroup like this:

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);


来源:https://stackoverflow.com/questions/3352358/overlay-two-bitmap-images-in-wpf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!