Public Shared Function CreateBitmap(ByVal icon As Icon) As Bitmap
Dim gDest As Graphics, gSrc As Graphics
Dim tmp As Bitmap
Dim hdcDest As IntPtr
Dim hdcSrc As Integer, hdcSrc2 As IntPtr
Dim hWnd As Integer = icon.Handle.ToInt32
gSrc = gSrc.FromImage(icon.ToBitmap())
tmp = New Bitmap(icon.Width, icon.Height)
gDest = gDest.FromImage(tmp)
hdcSrc2 = gSrc.GetHdc
hdcSrc = hdcSrc2.ToInt32()
hdcDest = gDest.GetHdc
Win32.BitBlt(hdcDest.ToInt32, 0, 0, icon.Width, icon.Height, hdcSrc, 0, 0, Win32.SRCCOPY)
gDest.ReleaseHdc(hdcDest)
gSrc.ReleaseHdc(hdcSrc2)
Win32.ReleaseDC(hWnd, hdcSrc)
Return tmp
End Function