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( 225 0 225 0 );
11         colorMap.NewColor  =  Color.FromArgb( 0 222 0 0 );
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),  0 0 , waterImage.Width, waterImage.Height, GraphicsUnit.Pixel, imageatta);
26         graphics.Dispose();
27         image.Save( base .Response.OutputStream, ImageFormat.Jpeg);
28         image.Dispose();
29         waterImage.Dispose();

 

转载于:https://www.cnblogs.com/byxxw/archive/2008/12/16/1355848.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值