我正面临这个错误
'ImageUtils.ImageTransparency'由于其保护而无法访问 水平
这是我的代码:
namespace ImageUtils
{
class ImageTransparency
{
public static Bitmap ChangeOpacity(Image img, float opacityvalue)
{
Bitmap bmp = new Bitmap(img.Width,img.Height);
Graphics graphics = Graphics.FromImage(bmp);
ColorMatrix colormatrix = new ColorMatrix();
colormatrix.Matrix33 = opacityvalue;
ImageAttributes imgAttribute = new ImageAttributes();
imgAttribute.SetColorMatrix(colormatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
graphics.DrawImage(img, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, imgAttribute);
graphics.Dispose();
return bmp;
}
}
}
我想用它来制作透明图像。我在这段代码中使用它:
protected void bntChangeOpacity_Click(object sender, EventArgs e)
{
Image watermarkImage = Image.FromFile(myImage);
using (TextureBrush watermarkBrush = new TextureBrush(watermarkImage))
{
Graphics gr = Graphics.FromImage(watermarkImage);
gr.FillRectangle(watermarkBrush, new Rectangle(new Point(0, 0), new Size(watermarkImage.Width, watermarkImage.Height)));
float opacityvalue = 50 / 100;
ImageUtils.ImageTransparency.ChangeOpacity(watermarkImage, opacityvalue);
}
}
请帮帮我..