Creating icons

K

K

Hi all, I have vb code below which convert image to icon but there
are two problem with this. One when i try to save 16 x 16 size icons,
it creates black bacground whith that icon. Two it saves 32 x 32 icon
ok but in different colours from the original image colours. I'll be
very greateful if any friend has sultion for this.


Dim img As New Bitmap(PictureBox1.Image, 32, 32)
Dim g As Graphics = Graphics.FromImage(img)
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(img, 0, 0)
Dim Hicon As IntPtr = img.GetHicon
Dim newicon As Icon = System.Drawing.Icon.FromHandle(Hicon)
Dim fpth As New IO.FileStream(RichTextBox2.Text & "\" &
RichTextBox3.Text & ".ico", IO.FileMode.Create)
newicon.Save(fpth)
newicon.Dispose()
MsgBox("Image has been converted", MsgBoxStyle.Information, "Done!")
 
H

Herfried K. Wagner [MVP]

Am 28.02.2010 10:59, schrieb K:
Hi all, I have vb code below which convert image to icon but there
are two problem with this. One when i try to save 16 x 16 size icons,
it creates black bacground whith that icon. Two it saves 32 x 32 icon
ok but in different colours from the original image colours.

You may want to use this library (untested):

IconLib - Icons Unfolded (MultiIcon and Windows Vista supported) -
CodeProject
<URL:http://www.codeproject.com/KB/cs/IconLib.aspx>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top