object IExtractIcon.ExtractIcon(ExtractIconType type, Size desiredSize) { if (type == ExtractIconType.Thumbnail) { //// Have we already extracted the image? //if (cachedImage != null) // return cachedImage; // Do we support this extension? string ext = base.File.Extension.ToLowerInvariant(); if (ext == ".mif") { #if false using (Stream stream = base.File.OpenRead()) using (QQGame.MifImageDecoder mif = new QQGame.MifImageDecoder(stream)) { // TODO: should we dispose the original image??? Image img = mif.DecodeFrame().Image; return (Image)img.Clone(); } #else Stream stream = base.File.OpenRead(); QQGame.MifImage mif = new QQGame.MifImage(stream); mif.Name = base.File.Name; return mif; #endif } else if (ext == ".bmp" || ext == ".png") { using (Stream stream = base.File.OpenRead()) using (Bitmap bmp = new Bitmap(stream)) { // Make a copy of the bitmap, because MSDN says "You must // keep the stream open for the lifetime of the Bitmap." return bmp.Clone(); } } } return null; }
string IExtractIcon.GetIconKey(ExtractIconType type, Size desiredSize) { if (type == ExtractIconType.Thumbnail) { return base.File.FullName; } else { return null; } }
string IExtractIcon.GetIconKey(ExtractIconType type, Size desiredSize) { return "Folder_Icon_16"; }
object IExtractIcon.ExtractIcon(ExtractIconType type, Size desiredSize) { return smallIcon.Clone(); }
// NOTE: The following implementation duplicates with ImageFile. // We need to consolidate and remove one of them. object IExtractIcon.ExtractIcon(ExtractIconType type, Size desiredSize) { if (type == ExtractIconType.Thumbnail) { // Do we support this extension? string ext = Path.GetExtension( entry.FullName).ToLowerInvariant(); if (ext == ".mif") { using (Stream stream = entry.Open()) { QQGame.MifImage mif = new QQGame.MifImage(stream); mif.Name = entry.FullName; return mif; } } else if (ext == ".bmp" || ext == ".png") { using (Stream stream = entry.Open()) using (Bitmap bmp = new Bitmap(stream)) { // Make a copy of the bitmap, because MSDN says "You must // keep the stream open for the lifetime of the Bitmap." return bmp.Clone(); } } else if (ext == ".tga") { using (Stream stream = entry.Open()) using (TgaImage tga = new TgaImage(stream)) { // Make a copy of the bitmap so that we can dispose // the TgaImage object. return tga.Image.Clone(); } } } return null; }
string IExtractIcon.GetIconKey(ExtractIconType type, Size desiredSize) { return "Package_Icon_16"; }