关于vb.net drawimage绘图透明度 纠结了好几天了 求指导
刚开始接触vb.net 现在想把一个控件做成渐变效果的,java里graphics2D有设置绘图透明度的方法,请问
vb.net 里有类似方法吗 我不是要把窗体都做成透明的 是想设置drawimage方法的透明度,求指导~
[解决办法]
控件透明度我也纠结了好久,但是没有...
[解决办法]
哦上面的错了,用这个
Private Function SetOpacity(ByVal B As Bitmap, ByVal D As Double) As Bitmap
Try
Dim bmpDATA As New BitmapData
Dim tmpBMP = New Bitmap(B)
Dim Rct As Rectangle = New Rectangle(0, 0, B.Width, B.Height)
bmpDATA = tmpBMP.LockBits(Rct, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb)
Dim BTS(bmpDATA.Stride * bmpDATA.Height) As Byte
Runtime.InteropServices.Marshal.Copy(bmpDATA.Scan0, BTS, 0, BTS.Length - 1)
Dim T As Double = 0
For I As Integer = 0 To BTS.Length - 4 Step 4
T = BTS(I + 3)
T = T * D
BTS(I + 3) = T
Next
Runtime.InteropServices.Marshal.Copy(BTS, 0, bmpDATA.Scan0, BTS.Length - 1)
tmpBMP.UnlockBits(bmpDATA)
Return tmpBMP
Catch
Return Nothing
End Try
End Function