G
Guest
I'm having a problem loading an Icon into an ImageList.
When I load the icon directly it works fine, like this:
Icon sourceIcon = << Get an icon from somewhere... >>;
treeViewImageList.Images.Add("abc", sourceIcon);
But when I first save the original icon to a stream and then try loading the
ImageList from the stream, the icon image is messed up. Here's that code:
Icon sourceIcon = << Get an icon from somewhere... >>;
MemoryStream imageStream = new MemoryStream();
sourceIcon.Save(imageStream);
imageStream.Position = 0;
Icon icon = new Icon(imageStream);
treeViewImageList.Images.Add("abc", icon);
The ultimate goal is to use the stream to save the icon byte array to a
database and then load it again later but first I need to be able to get the
icon to reload correctly from the stream.
Any ideas what I'm doing wrong here?
Thanks.
- Adam
When I load the icon directly it works fine, like this:
Icon sourceIcon = << Get an icon from somewhere... >>;
treeViewImageList.Images.Add("abc", sourceIcon);
But when I first save the original icon to a stream and then try loading the
ImageList from the stream, the icon image is messed up. Here's that code:
Icon sourceIcon = << Get an icon from somewhere... >>;
MemoryStream imageStream = new MemoryStream();
sourceIcon.Save(imageStream);
imageStream.Position = 0;
Icon icon = new Icon(imageStream);
treeViewImageList.Images.Add("abc", icon);
The ultimate goal is to use the stream to save the icon byte array to a
database and then load it again later but first I need to be able to get the
icon to reload correctly from the stream.
Any ideas what I'm doing wrong here?
Thanks.
- Adam