Beispiel #1
0
 /// <exception cref="System.IO.IOException"/>
 public static void SaveSegmentFiles([NotNull] string jpegFilePath, [NotNull] JpegSegmentData segmentData)
 {
     foreach (JpegSegmentType segmentType in segmentData.GetSegmentTypes())
     {
         IList <sbyte[]> segments = Iterables.ToList(segmentData.GetSegments(segmentType));
         if (segments.Count == 0)
         {
             continue;
         }
         if (segments.Count > 1)
         {
             for (int i = 0; i < segments.Count; i++)
             {
                 string outputFilePath = Sharpen.Extensions.StringFormat("%s.%s.%d", jpegFilePath, Sharpen.Extensions.ConvertToString(segmentType).ToLower(), i);
                 System.Console.Out.Println("Writing: " + outputFilePath);
                 FileUtil.SaveBytes(new FilePath(outputFilePath), segments[i]);
             }
         }
         else
         {
             string outputFilePath = Sharpen.Extensions.StringFormat("%s.%s", jpegFilePath, Sharpen.Extensions.ConvertToString(segmentType).ToLower());
             System.Console.Out.Println("Writing: " + outputFilePath);
             FileUtil.SaveBytes(new FilePath(outputFilePath), segments[0]);
         }
     }
 }
        private static void SaveSegmentFiles(string jpegFilePath, JpegSegmentData segmentData)
        {
            foreach (var segmentType in segmentData.GetSegmentTypes())
            {
                IList <byte[]> segments = segmentData.GetSegments(segmentType).ToList();

                if (segments.Count == 0)
                {
                    continue;
                }

                var format = segments.Count > 1 ? "{0}.{1}.{2}" : "{0}.{1}";

                for (var i = 0; i < segments.Count; i++)
                {
                    var outputFilePath = string.Format(format, jpegFilePath, segmentType.ToString().ToLower(), i);

                    Console.Out.WriteLine("Writing: " + outputFilePath);
                    File.WriteAllBytes(outputFilePath, segments[i]);
                }
            }
        }