改变不透明度我使用此功能在图片框
Public Shared Function ChangeOpacity(ByVal img As Image, ByVal opacityvalue As Single) As Bitmap
Dim bmp As New Bitmap(img.Width, img.Height)
Dim graphics__1 As Graphics = Graphics.FromImage(bmp)
Dim colormatrix As New colormatrix
colormatrix.Matrix33 = opacityvalue
Dim imgAttribute As New ImageAttributes
imgAttribute.SetColorMatrix(colormatrix, ColorMatrixFlag.[Default], ColorAdjustType.Bitmap)
graphics__1.DrawImage(img, New Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, img.Width, img.Height, _
GraphicsUnit.Pixel, imgAttribute)
graphics__1.Dispose()
Return bmp
End Function
我使用这个命令
picturebox.Image = ChangeOpacity(picturebox.Image,0.3)
这是工作,图片框的不透明度是消退。 但是当我尝试这个
picturebox.Image = ChangeOpacity(picturebox.Image,1.0)
它没有发生,画面依然淡出我要回图片到默认 如何解决这一问题? 非常感谢您
它的工作原理!谢谢 ! – user3709879
当您更改图片框中的图像时,您需要确保在旧图像上调用“Dispose”! –
@CodyGray现在检查它的先生。这是正确的? – Sathish