C# 合并两张图片

时间:2024-04-30 15:05:50
private BitmapSource CombineImage(BitmapSource img1,BitmapSource img2)
{
var composeImg = new RenderTargetBitmap(img1.PixelWidth,
img1.PixelHeight+img2.PixelHeight,
img1.DpiX,
img1.DpiY,
PixelFormat.Default ); var dv = new DrawingVisual();
using(var dc = dv.RenderOpen())
{
dc.DrawImage(img1,new Rect(,,img1.PixelWidth,img1.PixelHeight));
dc.DrawImage(img1,new Rect(,,img2.PixelWidth,img2.PixelHeight)); composeImg.Render(dv);
} return composeImg;
}