PDA

Click to See Complete Forum and Search --> : BMP to Ico code


Cbomb
Oct 15th, 2000, 09:48 AM
Does anyone know of some code that will load a BMP as an ICO? I have about 25 pics in BMP format and I dont want to convert them all to ICO using MicroAngelo or something..it would just be too tedious. And I have to use the pics as DragIcons

Thanks in advance

kedaman
Oct 15th, 2000, 09:50 AM
Add a Imagelist in your app, add the bitmap to the imagelist and use it's extracticon method to create the icon, savepicture directly with that icon without having it on the picturebox or it won't be in ico format

Oct 15th, 2000, 10:04 AM
Add the following code to a Form with an ImageList, PictureBox and CommandButton.

Private Sub Command1_Click()
ImageList1.ListImages.Add , "Pic1", Picture1.Picture
Picture1 = Nothing
Picture1 = ImageList1.ListImages(1).ExtractIcon
SavePicture Picture1, "C:\WINDOWS\DESKTOP\MYICON.ICO"
End Sub


Make sure there is a picture loaded in the PictureBox. When you press the CommandButton, it will convert the picture to an icon and save it on to your desktop with the name of MyIcon.ico.

Cbomb
Oct 15th, 2000, 01:37 PM
Ok i see how that works...and i thought i could modify it but i guess not.... this code gives me an "index out of bounds" error at: TileList.ListImages.Add i, "Tile" & Str(i), Tile(i).Picture


For i = 0 To 13
TileList.ListImages.Add i, "Tile" & Str(i), Tile(i).Picture
tmppic = Nothing
tmppic = TileList.ListImages(i).ExtractIcon
SavePicture tmp, "C:\Graphics\RPG\tiles\icons\Tile" & Str(i) & ".ico"
Next i


Can ya tell me what im doing wrong here?...thanks again

Cbomb
Oct 15th, 2000, 02:00 PM
Nevermind guys i got it..thanks for your help