【发布时间】:2016-09-02 14:07:29
【问题描述】:
我有一个包含图像的表单。我正在使用滑块来更改图像的不透明度。因此,在滑块的“ValueChanged”事件中,我调用了以下方法来更改不透明度。
//Setting the opacity of the image
public static Image SetImgOpacity(Image imgPic, float imgOpac)
{
Bitmap bmpPic = new Bitmap(imgPic.Width, imgPic.Height);
Graphics gfxPic = Graphics.FromImage(bmpPic);
ColorMatrix cmxPic = new ColorMatrix();
cmxPic.Matrix33 = imgOpac;
ImageAttributes iaPic = new ImageAttributes();
iaPic.SetColorMatrix(cmxPic, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
gfxPic.DrawImage(imgPic, new Rectangle(0, 0, bmpPic.Width, bmpPic.Height), 0, 0, imgPic.Width, imgPic.Height, GraphicsUnit.Pixel, iaPic);
gfxPic.Dispose();
return bmpPic;
}
返回的图像设置为原始图像。
我的问题是图像的不透明度没有改变...如果有任何错误请指出.. Thnx...
【问题讨论】:
标签: c# .net image image-processing