Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In this example, using the Bitmap class included in the System.Drawing namespace, a file is converted from .Ico to .Bmp to display it in a PictureBox.
This is necessary because the .Ico format is not supported by the PictureBox control.
VB
Public Class Form1
Public Function FromIconToBitmap(ByVal icon As Icon) As Bitmap
Dim bmp As New Bitmap(icon.Width, icon.Height)
Using gp As Graphics = Graphics.FromImage(bmp)
gp.Clear(Color.Transparent)
gp.DrawIcon(icon, New Rectangle(0, 0, icon.Width, icon.Height))
End Using
Return bmp
End Function
Private Sub Button1_Click(sender As System.Object,
e As System.EventArgs) Handles Button1.Click
Dim icon As Icon = My.Resources.Resources.Icon1
PictureBox1.Image = FromIconToBitmap(icon)
End Sub
End Class