首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我如何将图像写到另一个图像上?

我如何将图像写到另一个图像上?
EN

Stack Overflow用户
提问于 2014-05-25 07:30:20
回答 1查看 106关注 0票数 0

我有一个图像是500x500,对这个图像,我想复制一个符号是32x32,在500 x 500图像的右上角。

我试过把它渲染进去,但它似乎不起作用:

代码语言:javascript
复制
var statusSymbol = new Image()
{
      Source = new BitmapImage(new Uri(tempJPEG, UriKind.Relative))
};

WriteableBitmap wb = new WriteableBitmap(bitmap);
wb.Render(statusSymbol , new TranslateTransform() { X = 500-10, Y = 10 });
wb.Invalidate();
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-05-25 08:03:34

手动方式(及其优缺点):

代码语言:javascript
复制
 public Bitmap AddLogo(Bitmap original_image, Bitmap logo)
    {
        /// Add validation here (not null, logo smaller then original, etc..)
        Bitmap with_logo = new Bitmap(original_image);           

        /// To get the right corner use:
        int x_start_value = (original_image.Width - logo.Width) - 1;
        int x_stop_value = original_image.Width -1;
        /// 

        /// You can add ofset (padding) by starting x and\or y from your value insted of 0

        for (int y = 0; y < logo.Height; y++)            
        {

            /// For left corner
            ///for (int x = 0; x < logo.Width; x++)
            int logo_x = 0;
            for (int x = x_start_value; x < x_stop_value; x++)                
            {
                with_logo.SetPixel(x, y, logo.GetPixel(logo_x, y));
                logo_x++;
            }
        }

        return with_logo;
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23853054

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档