#region 添加水印图片
        /// <summary>
        /// 添加水印图片
        /// </summary>
        /// <param name="newwaterimage">imge 对象</param>
        /// <param name="WaterMarkPicPath">水印图片的地址</param>
        /// <param name="_width">水印位置</param>
        private static void AddWaterImage(System.Drawing.Image newwaterimage, string WaterMarkPicPath,ImageWaterPosition warterposition)
        {
            int _width = newwaterimage.Width;
            int _height = newwaterimage.Height;
            Graphics picture = Graphics.FromImage(newwaterimage);
            Image water = new Bitmap(WaterMarkPicPath);
            ImageAttributes imageAttributes = new ImageAttributes();
            ColorMap colorMap = new ColorMap();
            colorMap.OldColor = Color.FromArgb(255, 0, 255, 0);
            colorMap.NewColor = Color.FromArgb(0, 0, 0, 0);
            ColorMap[] remapTable = { colorMap };
            imageAttributes.SetRemapTable(remapTable, ColorAdjustType.Bitmap);
            float[][] colorMatrixElements = {
            new float[] {1.0f,  0.0f,  0.0f,  0.0f, 0.0f},
            new float[] {0.0f,  1.0f,  0.0f,  0.0f, 0.0f},
            new float[] {0.0f,  0.0f,  1.0f,  0.0f, 0.0f},
            new float[] {0.0f,  0.0f,  0.0f,  0.3f, 0.0f},
            new float[] {0.0f,  0.0f,  0.0f,  0.0f, 1.0f}
            };
            ColorMatrix colorMatrix = new ColorMatrix(colorMatrixElements);
            imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            int xpos = 0;
            int ypos = 0;
            int WaterWidth = 0;
            int WaterHeight = 0;
            double bl = 1d;
            //计算水印图片的比率
            //取背景的1/4宽度来比较
            if ((_width > water.Width * 4) && (_height > water.Height * 4))
            {
                bl = 1;
            }
            else if ((_width > water.Width * 4) && (_height < water.Height * 4))
            {
                bl = Convert.ToDouble(_height / 4) / Convert.ToDouble(water.Height);
            }
            else
            {
                if ((_width < water.Width * 4) && (_height > water.Height * 4))
                {
                    bl = Convert.ToDouble(_width / 4) / Convert.ToDouble(water.Width);
                }
                else
                {
                    if ((_width * water.Height) > (_height * water.Width))
                    {
                        bl = Convert.ToDouble(_height / 4) / Convert.ToDouble(water.Height);
                    }
                    else
                    {
                        bl = Convert.ToDouble(_width / 4) / Convert.ToDouble(water.Width);
                    }
                }
            }
            WaterWidth = Convert.ToInt32(water.Width * bl);
            WaterHeight = Convert.ToInt32(water.Height * bl);
            switch (warterposition)
            {
                case ImageWaterPosition.WM_TOP_LEFT:
                    xpos = 10;
                    ypos = 10;
                    break;
                case ImageWaterPosition.WM_TOP_RIGHT:
                    xpos = _width - WaterWidth - 10;
                    ypos = 10;
                    break;
                case ImageWaterPosition.WM_BOTTOM_RIGHT:
                    xpos = _width - WaterWidth - 10;
                    ypos = _height - WaterHeight - 10;
                    break;
                case ImageWaterPosition.WM_BOTTOM_LEFT:
                    xpos = 10;
                    ypos = _height - WaterHeight - 10;
                    break;
            }
            picture.DrawImage(water, new Rectangle(xpos, ypos, WaterWidth, WaterHeight), 0, 0, water.Width, water.Height, GraphicsUnit.Pixel, imageAttributes);
            water.Dispose();
            imageAttributes.Dispose();
            picture.Dispose();
        }
        #endregion
现在的水印是透明的,,我不想让它透明,怎么改。

解决方案 »

  1.   

    还有一个问题,由于我安装了sqlserver2008  我的vs2005变成了英文版(自己写的方法属性还是中文的)的了,怎么能改回到中文版
      

  2.   

    new float[] {1.0f,  0.0f,  0.0f,  0.0f, 0.0f}, 
                new float[] {0.0f,  1.0f,  0.0f,  0.0f, 0.0f}, 
                new float[] {0.0f,  0.0f,  1.0f,  0.0f, 0.0f}, 
                new float[] {0.0f,  0.0f,  0.0f,  0.3f, 0.0f}, 
                new float[] {0.0f,  0.0f,  0.0f,  0.0f, 1.0f} 
    matrix矩阵,红色的参数是可以改透明度的。