不是件容易的事                float[][] ptsArray =
                {
                    new float[] {1,0,0,0,0},
                    new float[] {0,1,0,0,0},
                    new float[] {0,0,1,0,0},
                    new float[] {0,0,0,0.5f,0},
                    new float[] {1,0,0,0,1}
                };其中的0.5f就是透明度为0.5

解决方案 »

  1.   

    你先把图片添加到Form上 然后把Form调摄下透明 应该可以吧
      

  2.   

    使用PNG格式。至于处理当然在Photoshop中了,如果不是动态图片。
      

  3.   

    C# 多个图片叠加,图片透明. 
    下载该示例代码using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Collections;using System.Drawing;
    using System.Drawing.Imaging;
    using System.Drawing.Drawing2D;namespace Haix.Utils
    {
        class GenerateImage
        {        
            public struct favoriteImage
            { 
                private string _imagePath;            
                private int _x;
                private int _y;
                
                public int x
                {
                    get 
                    {
                        return _x; 
                    }
                    set 
                    {
                        _x  = value;
                    }
                }            public int y
                {
                    get
                    {
                        return _y;
                    }
                    set
                    {
                        _y = value;
                    }
                }            public string imagePath
                {
                    get
                    {
                        return _imagePath;
                    }
                    set
                    {
                        _imagePath = value;
                    }
                }
            }                [STAThread]
            static void Main(string[] args)
            {
                string CurrentDirectory = System.Environment.CurrentDirectory;
                string body_path=CurrentDirectory + "\\white.png";             favoriteImage[] FaImage = new favoriteImage[2];
                
                FaImage[0].x = -3;
                FaImage[0].y = 70;
                FaImage[0].imagePath = CurrentDirectory + "\\1.png";            FaImage[1].x = 20;//65;
                FaImage[1].y = -12;
                FaImage[1].imagePath = CurrentDirectory + "\\2.png";            generateWinterMark(CurrentDirectory,body_path, FaImage);
            }        /**//// <summary>
            /// 生成水印
            /// </summary>
            /// <param name="Main">主图片路径,eg:body</param>
            /// <param name="Child">要叠加的图片路径</param>
            /// <param name="x">要叠加的图片位置的X坐标</param>
            /// <param name="y">要叠加的图片位置的Y坐标</param>
            /// <param name="isSave"></param>
            /// <returns>生成图片的路径</returns>        
            private static string generateWinterMark(string savePath,string body_path,favoriteImage[] favorite)
            {
                //create a image object containing the photograph to water
                Image imgPhoto = Image.FromFile(body_path);
                int phWidth = imgPhoto.Width;
                int phHeight = imgPhoto.Height;            //create a Bitmap the Size of the original photograph
                Bitmap bmPhoto = new Bitmap(phWidth, phHeight, PixelFormat.Format24bppRgb);            //设置此 Bitmap 的分辨率。 
                bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);            //load the Bitmap into a Graphics object 
                Graphics grPhoto = Graphics.FromImage(bmPhoto);
                //Set the rendering quality for this Graphics object
                grPhoto.SmoothingMode = SmoothingMode.AntiAlias;//清除锯齿的呈现
     //haix
                for (int i = 0; i < favorite.Length; i++)
                {  
                //Draws the photo Image object at original size to the graphics object.
                grPhoto.DrawImage(
                    imgPhoto,                               // Photo Image object
                    new Rectangle(0, 0, phWidth, phHeight), // Rectangle structure
                    0,                                      // x-coordinate of the portion of the source image to draw. 
                    0,                                      // y-coordinate of the portion of the source image to draw. 
                    phWidth,                                // Width of the portion of the source image to draw. 
                    phHeight,                               // Height of the portion of the source image to draw. 
                    GraphicsUnit.Pixel);                    // Units of measure              
                    //------------------------------------------------------------
                    //Step #2 - Insert Property image,For example:hair,skirt,shoes etc.
                    //------------------------------------------------------------
                    //create a image object containing the water
                    Image imgWater = new Bitmap(favorite[i].imagePath);
                    int wmWidth = imgWater.Width;
                    int wmHeight = imgWater.Height;
                                    //Create a Bitmap based on the previously modified photograph Bitmap
                    Bitmap bmWater = new Bitmap(bmPhoto);
                    bmWater.MakeTransparent(); //使默认的透明颜色对此 Bitmap 透明。                //bmWater.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);
                    //Load this Bitmap into a new Graphic Object
                    Graphics grWater = Graphics.FromImage(bmWater);
                    int xPosOfWm = favorite[i].x;
                    int yPosOfWm = favorite[i].y;                //叠加
                    grWater.DrawImage(imgWater,new Rectangle(xPosOfWm, yPosOfWm, wmWidth, wmHeight),  //Set the detination Position
                    0,                  // x-coordinate of the portion of the source image to draw. 
                    0,                  // y-coordinate of the portion of the source image to draw. 
                    wmWidth,            // Water Width
                    wmHeight,            // Water Height
                    GraphicsUnit.Pixel, // Unit of measurment
                    null);   //ImageAttributes Object
                    //Replace the original photgraphs bitmap with the new Bitmap
                    imgPhoto = bmWater;                //grWater.Dispose();
                    //imgWater.Dispose();
                    //grPhoto.Dispose();                
                    //bmWater.Dispose();
                }
                //haix            string nowTime = DateTime.Now.Year.ToString()+DateTime.Now.Month.ToString()+DateTime.Now.Day.ToString();
                nowTime += DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();            string saveImagePath = savePath + "\\FA" + nowTime + ".png";
                
                //save new image to file system.
                imgPhoto.Save(saveImagePath, ImageFormat.Png);            
                imgPhoto.Dispose();
                        return saveImagePath;
            }
        }
    }
    叠加后的图片:一个body,一个hair,一个西服:kaixin110 是一位Web工程师。他原来是在郑州一家软件公司做WebGIS (JSP+Servlet+Tomcat),对WebGIS的原理有一定研究,在狂热地编写代码之余,他喜欢打篮球并体验软件带给我们的惊喜。目前在中国深圳一公司做Web开发(ASP.NET),如果您希望就本文与 kaixin110联系,则可以通过[email protected]与他联系。 
    posted on 2007-08-03 15:07 kaixin110 阅读(444) 评论(3)  编辑  收藏 所属分类: Microsoft.NET  
    评论
    #1楼  2007-08-03 15:40 flyingfish 
    截个图上来看看阿!   回复  引用  查看     #2楼 [TrackBack] 2007-08-19 20:58 将飞 
    http://www.cnblogs.com/kaixin110/archive/2007/08/03/841827.html
    [引用提示]将飞引用了该文章, 地址: http://www.cnblogs.com/jfei1982/archive/2007/08/19/861895.html   回复  引用  查看     #3楼 [楼主] 2007-11-26 08:46 kaixin110 
    Bitmap bmWater = new Bitmap(bmPhoto); 
    bmWater.MakeTransparent(); //使默认的透明颜色对此 Bitmap 透明。 具体你可以调试code,然后自己看效果! 
    =======================================================
    http://www.cnblogs.com/kaixin110/archive/2007/08/03/841827.html
      

  4.   

    我觉得用C#太麻烦.\还是用PhotoShop处理好保存成PNG格式直接导入比较好
      

  5.   

    抠图啊
    用PS也行,C#也能实现简单背景的抠图。
      

  6.   


    管用,bmWater.MakeTransparent();