public static Image LoadFolderThumbnail(int width, int height, ThumbnailCache cache) { if (cache != null) { Image cachedThumbnail = cache.Get("FOLDER"); if (cachedThumbnail != null) { return(cachedThumbnail); } } var bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); Image img = Properties.Resources.Folder; int size = Math.Min(width, height); using (var g = Graphics.FromImage(bmp)) { g.DrawImage(img, (width - size) / 2, (height - size) / 2, size, size); } if (cache != null) { cache.Set("FOLDER", bmp); } return(bmp); }
private static Image CacheAndReturnImage(ThumbnailCache cache, string path, Image image) { if (cache != null) { cache.Set(path, image); } return(image); }