3d图像处理(将一个图像设置在另一图像上) [英] 3d Image Processing(Set one image on another image)

查看:73
本文介绍了3d图像处理(将一个图像设置在另一图像上)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有3d主图像,我想在运行时将另一个图像设置为主图像上的标签.我如何在WPF应用程序中做.请帮助我...

Hi,
I have master 3d image and i want to set at run time another image as a label on master image. How can i do in WPF application. Please help me......

推荐答案

从您的问题开始,假设您有两个图像:

1.请尝试使用此代码

(1)一个是主(baseImage)图像
(2)另一个是Label image(topImage)

首先,请将topImage覆盖在baseImage上.如果需要显示两个图像,请将透明度设置为较低的值.然后,将图像显示在想要显示的位置(无论是在WPF还是WinForms应用程序上).请先执行此操作,然后再实时显示图像.


From your question, let''s assume that you have two images:

1. Please try this code

(1) One is master (baseImage )image
(2) The other one is, Label image (topImage)

First, please overlay the topImage on the baseImage. If you need to show both images, set the transparency to lower value. Then, display the image where do you want it to display(whether it is on WPF or WinForms apps). Please do this before displaying the image on the fly.


public Image OverlayImage(Image baseImage, Image topImage, float transparency)
        {
            System.Drawing.Imaging.ImageAttributes ia = new     System.Drawing.Imaging.ImageAttributes();
            System.Drawing.Imaging.ColorMatrix cm = new System.Drawing.Imaging.ColorMatrix();
            cm.Matrix33 = transparency;
            ia.SetColorMatrix(cm);
            Graphics g = null;
            try
            {
                g = Graphics.FromImage(baseImage);                              
                Rectangle rect = new Rectangle((int)(topImage.Width * 0.1), (int)(topImage.Height * 0.2), (int)(topImage.Width * 0.8), (int)(topImage.Height * 0.6));
                // YOU MAY DEFINE THE RECT AS THIS AS WELL
                //Rectangle rect = new Rectangle(0, 0, baseImage.Width,      baseImage.Height, baseImage.Width);
                g.DrawImage(topImage, rect, 0, 0, topImage.Width, topImage.Height, GraphicsUnit.Pixel, ia);
                return baseImage;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                g.Dispose();
                topImage.Dispose();
            }
          
        }



2.我仅将以上代码用于Format32bppIndexed格式.众所周知,图像格式很多.如果要使用第三方,请尝试此操作.它具有叠加和水印功能,也适合您的问题:
http://www.artuxsoft.com/ [^ ]



2. I only make the above code for Format32bppIndexed format. As we know there are many image formats. If you want to use third party, please try this. It has Overlay and watermark functionalities which suite for your questions as well:
http://www.artuxsoft.com/[^]


这篇关于3d图像处理(将一个图像设置在另一图像上)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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