By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,472 Members | 1,168 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,472 IT Pros & Developers. It's quick & easy.

Export ImageList images

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

TIA
Kejpa
Nov 21 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
"Kejpa" <kS*******@saj.fi> schrieb:
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
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #2

P: n/a
"Kejpa" <kS*******@saj.fi> schrieb:
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
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #3

P: n/a
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
"Kejpa" wrote:
Hi,
does anyone have a sub for exporting the images (all or selected) of an
imagelist as files?

TIA
Kejpa

Nov 21 '05 #4

P: n/a
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
"Kejpa" wrote:
Hi,
does anyone have a sub for exporting the images (all or selected) of an
imagelist as files?

TIA
Kejpa

Nov 21 '05 #5

P: n/a
It's that simple...
I'm embarrased.

Thanx a lot!
/Kejpa
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
"Kejpa" <kS*******@saj.fi> schrieb:
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
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #6

P: n/a
It's that simple...
I'm embarrased.

Thanx a lot!
/Kejpa
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
"Kejpa" <kS*******@saj.fi> schrieb:
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
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #7

P: n/a
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
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
"Kejpa" <kS*******@saj.fi> schrieb:
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
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.