Export ImageList images

  • Thread starter Thread starter Kejpa
  • Start date Start date
K

Kejpa

Hi,
does anyone have a sub for exporting the images (all or selected) of an
imagelist as files?

TIA
Kejpa
 
Kejpa said:
does anyone have a sub for exporting the images (all or
selected) of an imagelist as files?

\\\
Dim i As Integer
For i = 0 To Me.ImageList1.Images.Count - 1
Me.ImageList1.Images(i).Save(i.ToString & ".bmp")
Next i
///
 
Hi Kejpa

Try this for starters:

You would want to add in checking for the directory existing, and handle
file extensions better - but you get the idea.

HTH

Nigel

Code to use the module:

Util.ImageListToFiles(Me.ImageList1, "C:\test\",
System.Drawing.Imaging.ImageFormat.Jpeg)

Module:

Public Module Util
Sub ImageListToFiles(ByVal list As ImageList, ByVal rootDirectory As
String, ByVal format As System.Drawing.Imaging.ImageFormat)
Dim i As Integer = 0
For Each im As Image In list.Images
' format.ToString is a bit of a hack...you would probably want to
' do a Select Case on it to get more control over the file
extension
im.Save(rootDirectory & i & "." & format.ToString(), format)
i += 1
Next
End Sub
End Module
 
Hmmm,
back at the office after a short cold and I try your code but it won't work
with icons. I can export the images as bmp's but then I loose the
transparent part. :(

any ideas?

TIA
/Kejpa
 
Back
Top