我该如何合并两个图像为一体? [英] How can I merge two images into one?

查看:227
本文介绍了我该如何合并两个图像为一体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大约70%不透明度面具的形象,我有一个从服务器下载其他图像。我该如何重绘他们向已下载的图像权奠定面膜图像下方单一的形象?我不想用的帆布,因为我将使用全景背景合并图像和画布是行不通的。

事情是这样的:

 使用(图形grfx = Graphics.FromImage(图片))
{
    grfx.DrawImage(newImage中,x,y)的
}

我试过,但没有运气:

 的BitmapImage BMP =新的BitmapImage();
        BitmapImage的双向=新的BitmapImage();        的ImageBrush的ImageBrush =新的ImageBrush();
        的ImageBrush imageBrush2 =新的ImageBrush();        bi.UriSource =新的URI(图像/的MainPage / mask_bg.png,UriKind.Relative);
        bmp.UriSource =新的URI(图像/的MainPage / covertart_bg.jpg,UriKind.Relative);        TranslateTransform翻译=新TranslateTransform
        {
            X = 0,
            Y = 0
        };
        imageBrush.ImageSource = BMP;
        ImageCanvas帆布=新ImageCanvas();
        canvas.Background =的ImageBrush;        WriteableBitmap的w_bitmap =新的WriteableBitmap的(1065,800);
        w_bitmap.Render(帆布,翻译);
        w_bitmap.Invalidate();        imageBrush2.ImageSource = w_bitmap;
        mainPanorama.Background = imageBrush2;


解决方案

使用从的 BLIT 方法=HTTP://writeablebitmapex.$c$ cplex.com/相对=nofollow> WriteableBitmapEx 项目

I have a mask image with opacity about 70%, and I have another image that is downloaded from server. How can I redraw them to single image that have the downloaded image lay right below the mask image? I don't want to use canvas because I will use the merge image for panorama background, and canvas wouldn't work.

Something like this:

using (Graphics grfx = Graphics.FromImage(image))
{
    grfx.DrawImage(newImage, x, y)
}

I tried this but no luck:

        BitmapImage bmp = new BitmapImage();
        BitmapImage bi = new BitmapImage();

        ImageBrush imageBrush = new ImageBrush();
        ImageBrush imageBrush2 = new ImageBrush();

        bi.UriSource = new Uri("Images/MainPage/mask_bg.png", UriKind.Relative);
        bmp.UriSource = new Uri("Images/MainPage/covertart_bg.jpg", UriKind.Relative);

        TranslateTransform translate = new TranslateTransform
        {
            X = 0,
            Y = 0
        };
        imageBrush.ImageSource = bmp;
        ImageCanvas canvas = new ImageCanvas();
        canvas.Background = imageBrush;

        WriteableBitmap w_bitmap = new WriteableBitmap(1065, 800);
        w_bitmap.Render(canvas, translate);
        w_bitmap.Invalidate();

        imageBrush2.ImageSource = w_bitmap;
        mainPanorama.Background = imageBrush2;

解决方案

Use the Blit method from the WriteableBitmapEx project

这篇关于我该如何合并两个图像为一体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆