设置图片的透明度
来源:互联网 发布:索福瑞收视数据 编辑:程序博客网 时间:2024/04/30 06:36
/// <summary>
/// 设置图片的透明度
/// </summary>
/// <param name="image">原图</param>
/// <param name="alpha">透明度0-255</param>
/// <returns></returns>
private Bitmap SetPictureAlpha(Image image,int alpha)
{
//颜色矩阵
float[][] matrixItems =
{
new float[]{1,0,0,0,0},
new float[]{0,1,0,0,0},
new float[]{0,0,1,0,0},
new float[]{0,0,0,alpha/255f,0},
new float[]{0,0,0,0,1}
};
ColorMatrix colorMatrix = new ColorMatrix(matrixItems);
ImageAttributes imageAtt = new ImageAttributes();
imageAtt.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
Bitmap bmp = new Bitmap(image.Width, image.Height);
Graphics g = Graphics.FromImage(bmp);
g.DrawImage(image, new Rectangle(0, 0, image.Width, image.Height),
0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAtt);
g.Dispose();
return bmp;
}
/// 设置图片的透明度
/// </summary>
/// <param name="image">原图</param>
/// <param name="alpha">透明度0-255</param>
/// <returns></returns>
private Bitmap SetPictureAlpha(Image image,int alpha)
{
//颜色矩阵
float[][] matrixItems =
{
new float[]{1,0,0,0,0},
new float[]{0,1,0,0,0},
new float[]{0,0,1,0,0},
new float[]{0,0,0,alpha/255f,0},
new float[]{0,0,0,0,1}
};
ColorMatrix colorMatrix = new ColorMatrix(matrixItems);
ImageAttributes imageAtt = new ImageAttributes();
imageAtt.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
Bitmap bmp = new Bitmap(image.Width, image.Height);
Graphics g = Graphics.FromImage(bmp);
g.DrawImage(image, new Rectangle(0, 0, image.Width, image.Height),
0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAtt);
g.Dispose();
return bmp;
}
- 设置图片的透明度
- C++Builder 设置图片的透明度
- android 如何设置图片颜色的透明度
- Java如何设置图片的透明度
- android 如何设置图片颜色的透明度
- CSS 设置图片透明度
- android设置图片透明度
- 设置图片透明度
- 给图片设置透明度。
- BitMap设置图片透明度
- javascript 设置图片透明度与图片的水平垂直旋转
- 设置图片透明度alpha注意
- CSS设置网页图片透明度
- css如何设置图片透明度
- css图片透明度设置问题
- android开发设置图片透明度的2种方法
- flash如何设置、调整、修改图片的透明度
- 图片透明度的处理
- 爱刻薄讥讽别人的人其实内心不幸福
- C#获取当前路径的方法
- 毕业典礼上的演讲
- 19个非常有用的 jQuery 图片滑动插件和教程
- 10. 9. 1. 丑陋的表 Create a thread to update Swing
- 设置图片的透明度
- jQuery实现按比例缩放图片
- 10个有用的jquery 图片插件
- jQuery图片切换效果
- 骨骼动画资料搜集
- 哈希表,哈希算法,MD5加密算法初识
- 挚爱,执手一生,互爱彼此,共生共荣,不离不弃
- 分享30个最佳 jQuery Lightbox 效果插件
- 因为史蒂夫,世界变得更加美好的程度是不可估量的