Hi

I need to create an application that converts an image to an icon. This is for a school project, and I know there are libraries in VB that do image conversion, however I have to make the conversion process myself. My first task is to convert an JPEG into an icon. I made the GUI, and have the program open up the files and scale them down into my pictureBox. What I need, are some suggestions for the conversion, since I can't use what VB has. what do I need to start with ?

Thanks.

Try this,

fileName = "test.jpg"
newFileName = "test.ico"

Dim bmp as System.Drawing.Bitmap= System.Drawing.Image.FromFile(fileName, true)  
Dim ico as System.Drawing.Icon = System.Drawing.Icon.FromHandle(bmp.GetHicon())
Dim icofs as Stream = File.Create(newFileName)
ico.Save(icofs)
icofs.Close()

Thanks but the thing is I can't use the System.Drawing object from VB. I have to come up with the conversion method without using the System.Drawing object. But thanks for the reply.

Or try this :)

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        PictureBox1.ImageLocation = "C:\\image.jpg"
        '
        Dim bm As Bitmap = New Bitmap(PictureBox1.ClientSize.Width, PictureBox1.ClientSize.Height)
        PictureBox1.DrawToBitmap(bm, PictureBox1.ClientRectangle)
        bm.Save("C:\test.ico", System.Drawing.Imaging.ImageFormat.Icon)

        PictureBox2.ImageLocation = "C:\\test.ico"
    End Sub
    
End Class

Software developer

Thank you I will try that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.