本文介绍了在WPF中叠加/合并图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我的表单上有两个图像,一个是.jpg,另一个是.png.我正在做的就是覆盖它们,以尝试创建一张图像,然后将其保存到文件中.我在网上做了很多搜索,但似乎找不到简单的方法来做.我有下面的代码,我认为这两个代码已合并为MyImage.然后如何将其保存到.jpg文件?
另外,有人知道这样做的好方法吗?
Hi all,
I have two images on my form, one is a .jpg the other is a .png. What I''m doing is overlaying them to try and create one image that I can then save to a file. I''ve done a lot of searching on the net but can''t seem to find a simple way to do it. I''ve got the code below which I think has amalgamated the two images into MyImage. How can I then save this to a .jpg file?
Alternativelyy, does anyone know of a nice easy way to do this?
public static void Overlay(ImageSource first, ImageSource second)
{
((BitmapFrame)first).Decoder.ToString();
var group = new DrawingGroup();
group.Children.Add(new ImageDrawing(new BitmapImage(new Uri(((BitmapFrame)first).Decoder.ToString(), UriKind.Absolute)),
new Rect(0, 0, first.Width, first.Height)));
group.Children.Add(new ImageDrawing(new BitmapImage(new Uri(((BitmapFrame)second).Decoder.ToString(), UriKind.Absolute)),
new Rect(0, 0, first.Width, first.Height)));
Image MyImage = new Image();
MyImage.Source = new DrawingImage(group);
}
谢谢大家,
Jib
Thanks all,
Jib
推荐答案
这篇关于在WPF中叠加/合并图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!