简单文字图片水印效果 - C#WinForm
2009-04-15 10:17
447 查看
对应代码下载:http://download.csdn.net/source/1210790
//原始图片 public void originalImage() { String sourcePath = @"../../Resources/test.jpg"; System.Drawing.Image image = System.Drawing.Image.FromFile(sourcePath); resultImage.Image = image; } //加文字水印 public void makeWordWatermark() { String sourcePath = @"../../Resources/test.jpg"; System.Drawing.Image image = System.Drawing.Image.FromFile(sourcePath); System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(image); graphics.DrawImage(image, 0, 0, image.Width, image.Height); System.Drawing.Font font = new System.Drawing.Font("Verdana", 30); System.Drawing.Brush brush = new System.Drawing.SolidBrush(System.Drawing.Color.White); string addText = "图片添加文字水印效果"; graphics.DrawString(addText, font, brush, 10, 10); graphics.Dispose(); resultImage.Image = image; } //图片整体设置透明度 public void makeImageWatermark() { String sourcePath = @"../../Resources/test.jpg"; String copyPath = @"../../Resources/image.jpg"; System.Drawing.Image image = System.Drawing.Image.FromFile(sourcePath); System.Drawing.Image copyImage = System.Drawing.Image.FromFile(copyPath); Graphics g = Graphics.FromImage(image); //透明度设置 float alpha = 0.15f; //ImageAttributes 对象包含有关在呈现时如何操作位图和图元文件颜色的信息。 ImageAttributes imageAttributes = new ImageAttributes(); //Colormap: 定义转换颜色的映射 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}, // red红色 new float[] {0.0f, 1.0f, 0.0f, 0.0f, 0.0f}, //green绿色 new float[] {0.0f, 0.0f, 1.0f, 0.0f, 0.0f}, //blue蓝色 new float[] {0.0f, 0.0f, 0.0f, alpha, 0.0f}, //透明度 new float[] {0.0f, 0.0f, 0.0f, 0.0f, 1.0f}}; // ColorMatrix:定义包含 RGBA 空间坐标的 5 x 5 矩阵。 // ImageAttributes 类的若干方法通过使用颜色矩阵调整图像颜色。 ColorMatrix wmColorMatrix = new ColorMatrix(colorMatrixElements); imageAttributes.SetColorMatrix(wmColorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); g.DrawImage(copyImage, new Rectangle(image.Width - copyImage.Width, image.Height - copyImage.Height, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, GraphicsUnit.Pixel, imageAttributes); g.Dispose(); resultImage.Image = image; }
相关文章推荐
- 文字图片水印效果(较复杂)-C#WinForm
- C# GDI+ 简单实现图片写文字和图片叠加(水印)
- 。net 根据高宽比例压缩图片,并给简单的文字水印……
- Asp.net(C#)给图片加上水印效果
- 图像处理------简单数字水印 - 文字轧花效果
- Asp.net(C#)给图片加上水印效果
- 使用ASP.net(C#)批量上传图片并自动生成缩略图,文字水印图,图片水印图
- sql server 关于表中只增标识问题 C# 实现自动化打开和关闭可执行文件(或 关闭停止与系统交互的可执行文件) ajaxfileupload插件上传图片功能,用MVC和aspx做后台各写了一个案例 将小写阿拉伯数字转换成大写的汉字, C# WinForm 中英文实现, 国际化实现的简单方法 ASP.NET Core 2 学习笔记(六)ASP.NET Core 2 学习笔记(三)
- Asp.net(C#)给图片加上水印效果
- C# WinForm中工具栏上如何既显示文字又显示图片
- Asp.net(C#)给图片加上水印效果
- ASP.NET(C#)图片加文字、图片水印
- C#给图片加水印的简单实现方法
- C# 图片缩略图,图片水印,文字水印
- C# 给图片加水印效果
- ASP.NET(C#)图片加文字、图片水印
- C# 上传图片,生成缩略图,生成文字或图像水印图
- C#给图片添加右下角斜角文字水印
- ps简单去除图片上的文字水印方法介绍
- Asp.net(C#)给图片加上水印效果