Source Code of bmp to icon file

 Source Code of bmp to icon file
 
 *********************************************************

Imports System.Security.Permissions
Public Class Form1
    <SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags:=SecurityPermissionFlag.UnmanagedCode)> Public Function GetHicon() As IntPtr
    End Function
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ofd As New OpenFileDialog
        Dim sfd As New SaveFileDialog
        Dim bitmap As Bitmap
        Dim HIcon As IntPtr
        Dim newIcon As Icon
        Dim oFileStream As IO.FileStream
        ofd.Filter = "Bitmap File|*.bmp"
        If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
            TextBox1.Text = ofd.FileName
          bitmap = New Bitmap(ofd.FileName)
            HIcon = bitmap.GetHicon()
            newIcon = System.Drawing.Icon.FromHandle(HIcon)
            sfd.DefaultExt = ".ico"
            If sfd.ShowDialog = Windows.Forms.DialogResult.OK Then
                oFileStream = New IO.FileStream(sfd.FileName, IO.FileMode.CreateNew)
                newIcon.Save(oFileStream)
                oFileStream.Close()
            End If
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class
********************** End Project ***************************

Comments

Popular posts from this blog

Complete Python Database Project with sqlite3

Complete StopWatch in Java with source code

System sound recorder using NAudio dll with complete code