c#在已有图片上打水印打码打矩形区域标记等

在为公安系统开发时,需要在图片上添加水印和矩形标记。以下C#代码展示了如何实现这一功能,包括创建文字水印和填充矩形区域。通过Graphics对象进行绘图,使用GraphicsPath创建矩形,并用SolidBrush填充颜色。最后保存处理后的图片到文件。
摘要由CSDN通过智能技术生成

最近在给公安系统做系统,需要在图片上打上水银等等,好吧直接看代码 

 protected void SetPicDescription(string filePath)
        {
            if (System.IO.File.Exists(filePath))//看该路径下图片是否存在  
            {
                string strDescription = "公安部水印测试";//文字描述  
                System.IO.MemoryStream ms = new System.IO.MemoryStream(System.IO.File.ReadAllBytes(filePath));
                Image image = Image.FromStream(ms);
                Graphics g = Graphics.FromImage(image);


                GraphicsPath gp = new GraphicsPath();






                //画图形填充区域开始
                Rectangle rec = new Rectangle(new Point(500, 500), new Size(100, 100));
                gp.AddEllipse(rec);
                g.DrawRectangle(new Pen(Color.White), rec);
                Color customColor = Color.FromArgb(255, Color.Gray);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值