Listview icons - how to extract icons to hdd?

A

Alain Dekker

I've got a ListView that a previous developer has added a number of icons
into. The "LargeImageList" member has a collection of 64x64 images which can
then be associated with each ListViewItem in the ListView.

My question is: I cannot find the 64x64 images used to generate the list.
How do I extract the images from the ListView to disk?

Thanks,
Alain
 
A

Alain Dekker

Thanks, I took your advice and extracted the files in situ with this code:

int nCount = lstlanguages.Items.Count;
string strFilename;
for (int nImage = 0; nImage < nCount; nImage++)
{
strFilename = ("\\FFSDISK\\BMP" + (nImage+1).ToString() + ".bmp");
lstlanguages.LargeImageList.Images[nImage].Save(strFilename,
System.Drawing.Imaging.ImageFormat.Bmp);

strFilename = ("\\FFSDISK\\GIF" + (nImage+1).ToString() + ".gif");
lstlanguages.LargeImageList.Images[nImage].Save(strFilename,
System.Drawing.Imaging.ImageFormat.Gif);

strFilename = ("\\FFSDISK\\JPEG" + (nImage+1).ToString() + ".jpg");
lstlanguages.LargeImageList.Images[nImage].Save(strFilename,
System.Drawing.Imaging.ImageFormat.Jpeg);

strFilename = ("\\FFSDISK\\PNG" + (nImage+1).ToString() + ".png");
lstlanguages.LargeImageList.Images[nImage].Save(strFilename,
System.Drawing.Imaging.ImageFormat.Png);
}

I did it in 4 formats to cover all bases. This does extract the images in a
variety of formats...but all the image backgrounds are Black! There was some
text embedded into the images which are visible in the control when the
application is running and this text has been blotted out with the black
background.

What should I do to extract the images precisely as I see them on-screen?

Thanks,
Alain
 
J

Jeff Johnson

I did it in 4 formats to cover all bases.

There was no point in that. You only need one format, and I would recommend
PNG.
This does extract the images in a variety of formats...but all the image
backgrounds are Black!

The icons apparently have transparency in them. I'm surprised the the PNG
format didn't come out right. It's the only one there that supports a full
alpha channel. (GIF supports transparency, but GIF is ancient and shouldn't
be used anymore for the most part.)
There was some text embedded into the images which are visible in the
control when the application is running and this text has been blotted out
with the black background.

What should I do to extract the images precisely as I see them on-screen?

I don't know. Like I said, I would have expected it to work with PNG.

Does the image list have its TransparentColor property set to anything?
 

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

Top