Beispiel #1
0
 private static IEnumerable<ZipEntry> GetBitmapEntries(ZipFile file)
 {
     using(IEnumeration entries = file.Entries())
     {
         while(entries.HasMoreElements)
         {
             var entry = (ZipEntry)entries.NextElement();
             if (!entry.IsDirectory
                 && (entry.Name.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase) 
                     || entry.Name.EndsWith(".jpeg", StringComparison.OrdinalIgnoreCase)
                     || entry.Name.EndsWith(".gif", StringComparison.OrdinalIgnoreCase)
                     || entry.Name.EndsWith(".png", StringComparison.OrdinalIgnoreCase)))
             {
                 yield return entry;
             }
         }
     }
 }
Beispiel #2
0
 public static Comics FromPath(string path)
 {
     Comics comics = new Comics(path);
     using(var zip = new ZipFile(path))
     {
         comics.Bitmaps = GetBitmapEntries(zip)
             .OrderBy(entry => entry.Name)
             .Select(entry =>
                 {
                     using (var stream = zip.GetInputStream(entry))
                     {
                         return stream.ReadFully();
                     }
                 })
             .ToArray();
     }
     return comics;
 }