mirror of
https://github.com/crskycode/GARbro.git
synced 2026-07-08 01:30:18 +08:00
archive extraction methods moved to a separate internal class.
This commit is contained in:
@@ -313,30 +313,5 @@ namespace GARbro.GUI
|
||||
}, DispatcherPriority.ContextIdle);
|
||||
}
|
||||
}
|
||||
|
||||
void ExtractImage (ArcFile arc, Entry entry, ImageFormat target_format)
|
||||
{
|
||||
using (var file = arc.OpenEntry (entry))
|
||||
{
|
||||
string source_ext = Path.GetExtension (entry.Name).TrimStart ('.').ToLowerInvariant();
|
||||
if (target_format.Extensions.Any (ext => ext == source_ext))
|
||||
{
|
||||
// source extension matches target image format, copy file as is
|
||||
using (var output = arc.CreateFile (entry))
|
||||
file.CopyTo (output);
|
||||
return;
|
||||
}
|
||||
ImageData image = ImageFormat.Read (file);
|
||||
if (null == image)
|
||||
throw new InvalidFormatException (string.Format ("{1}: {0}", guiStrings.MsgUnableInterpret, entry.Name));
|
||||
string target_ext = target_format.Extensions.First();
|
||||
string outname = Path.ChangeExtension (entry.Name, target_ext);
|
||||
Trace.WriteLine (string.Format ("{0} => {1}", entry.Name, outname), "ExtractImage");
|
||||
using (var outfile = ArchiveFormat.CreateFile (outname))
|
||||
{
|
||||
target_format.Write (outfile, image);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user