c#改变图片透明度
2017-10-04 08:53
274 查看
全栈工程师开发手册 (作者:栾鹏)
c#教程全解
c#改变图片透明度,需要保存成png格式,透明度参数alpha的取值范围为0-255
测试函数
改变透明度的函数
图片读取和存储函数
c#教程全解
c#改变图片透明度,需要保存成png格式,透明度参数alpha的取值范围为0-255
测试函数
static void Main() { Bitmap b = file2img("test.jpg"); Bitmap bb = img_alpha(b,200); img2file(bb, "test1.png"); }
改变透明度的函数
public static Bitmap img_alpha(Bitmap src, int alpha) { Bitmap bmp = new Bitmap(src.Width, src.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); for (int h = 0; h < src.Height; h++) for (int w = 0; w < src.Width; w++) { Color c = src.GetPixel(w, h); bmp.SetPixel(w, h, Color.FromArgb(alpha, c.R, c.G, c.B));//色彩度最大为255,最小为0 } return bmp; }
图片读取和存储函数
//图片读取 public static Bitmap file2img(string filepath) { Bitmap b = new Bitmap(filepath); return b; } //图片生成 public static void img2file(Bitmap b, string filepath) { b.Save(filepath); }
相关文章推荐
- C# 改变图片width height dpi 方法
- C# - 让窗口随图片自动改变大小
- ImageView图片轮播,放大缩小,改变图片透明度
- 图片列表:鼠标移入移出改变图片的透明度
- 鼠标移入/移出改变图片透明度_jQuery效果
- C#给图片加水印标记(可设置透明度)比上一篇好点,但只有一个方法
- SeekBar改变图片透明度
- 通过星级改变图片的透明度
- Loner_Li JQuery之 通过‘Select’ 标签 改变图片的透明度
- Android课程---用进度条改变图片透明度
- C#给图片加水印,可设置透明度
- c# GDI+改变图片保存时的质量
- 改变PNG图片的透明度 delphi
- Android 使用颜色矩阵改变图片颜色,透明度,亮度
- Android中改变一个图片的透明度
- android脚步---简单图片浏览器改变图像透明度
- 【安卓】拖动滑块改变图片的透明度
- C# 水印透明度图片
- c# picturebox随图片改变大小
- c# 改变图片大小