Esempio n. 1
0
 void ExtractImage(ArcFile arc, Entry entry, ImageFormat target_format)
 {
     using (var file = arc.OpenSeekableEntry(entry))
     {
         var src_format = ImageFormat.FindFormat(file, entry.Name);
         if (null == src_format)
         {
             throw new InvalidFormatException(string.Format("{1}: {0}", guiStrings.MsgUnableInterpretImage, entry.Name));
         }
         file.Position = 0;
         string target_ext = target_format.Extensions.FirstOrDefault() ?? "";
         string outname    = FindUniqueFileName(entry.Name, target_ext);
         if (src_format.Item1 == target_format)
         {
             // source format is the same as a target, copy file as is
             using (var output = ArchiveFormat.CreateFile(outname))
                 file.CopyTo(output);
             return;
         }
         ImageData image = src_format.Item1.Read(file, src_format.Item2);
         if (m_adjust_image_offset)
         {
             image = AdjustImageOffset(image);
         }
         using (var outfile = ArchiveFormat.CreateFile(outname))
         {
             target_format.Write(outfile, image);
         }
     }
 }
Esempio n. 2
0
        public static void ConvertAudio(string entry_name, SoundInput input)
        {
            string source_format = input.SourceFormat;

            if (GarConvertMedia.CommonAudioFormats.Contains(source_format))
            {
                string output_name = FindUniqueFileName(entry_name, source_format);
                using (var output = ArchiveFormat.CreateFile(output_name))
                {
                    input.Source.Position = 0;
                    input.Source.CopyTo(output);
                }
            }
            else
            {
                string output_name = FindUniqueFileName(entry_name, "wav");
                using (var output = ArchiveFormat.CreateFile(output_name))
                    AudioFormat.Wav.Write(input, output);
            }
        }