C#水印

 1        base.Response.ContentType = "image/jpeg";
 2        Bitmap image = new Bitmap(Server.MapPath("2008-12-31.jpg"));
 3        Bitmap waterImage = new Bitmap(Server.MapPath("74.png"));
 4
 5        Graphics graphics = Graphics.FromImage(image);
 6        graphics.InterpolationMode = InterpolationMode.High;
 7        graphics.SmoothingMode = SmoothingMode.HighQuality;
 8        ImageAttributes imageatta = new ImageAttributes();
 9        ColorMap colorMap = new ColorMap();
10        colorMap.OldColor = Color.FromArgb(22502250);
11        colorMap.NewColor = Color.FromArgb(022200);
12        ColorMap[] RemapTable = { colorMap };
13        //imageatta.SetRemapTable(RemapTable, ColorAdjustType.Bitmap);
14        float[][] colorMatrixElm = {
15            new float[] {10000},
16            new float[] {01000},
17            new float[] {00100},
18            new float[] {0000.5f0}
19            new float[] {00001}
20        }
;
21        ColorMatrix colorMatrix = new ColorMatrix(colorMatrixElm);
22        imageatta.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
23        int yPos = 0;
24        int xPos = 0;
25        graphics.DrawImage(waterImage, new Rectangle(xPos, yPos, waterImage.Width, waterImage.Height), 00, waterImage.Width, waterImage.Height, GraphicsUnit.Pixel, imageatta);
26        graphics.Dispose();
27        image.Save(base.Response.OutputStream, ImageFormat.Jpeg);
28        image.Dispose();
29        waterImage.Dispose();

 

posted @ 2008-12-16 11:28  不要相信我  阅读(896)  评论(0编辑  收藏  举报