private ImageList MakeResizedImageList(int width, int height, ImageList source)
{
ImageList il = new ImageList();
il.ImageSize = new Size(width, height);
il.ColorDepth = ColorDepth.Depth32Bit;
// If there's nothing to copy, just return the new list
if (source == null)
return il;
il.TransparentColor = source.TransparentColor;
il.ColorDepth = source.ColorDepth;
// Fill the imagelist with resized copies from the source
for (int i = 0; i < source.Images.Count; i++) {
Bitmap bm = this.MakeResizedImage(width, height, source.Images[i], source.TransparentColor);
il.Images.Add(bm);
}
// Give each image the same key it has in the original
foreach (String key in source.Images.Keys) {
il.Images.SetKeyName(source.Images.IndexOfKey(key), key);
}
return il;
}