public override ImageData Read(IBinaryStream stream, ImageMetaData info) { var meta = (GyuMetaData)info; if (0 == meta.Key) { bool got_key = false; var name = Path.GetFileNameWithoutExtension(meta.FileName); int num; if (int.TryParse(name, out num)) { if (null == CurrentMap) { CurrentMap = QueryScheme(); } got_key = CurrentMap != null && CurrentMap.TryGetValue(num, out meta.Key); } if (!got_key) { CurrentMap = null; throw new UnknownEncryptionScheme("Unknown image encryption key"); } } var reader = new GyuReader(stream.AsStream, meta); reader.Unpack(); return(ImageData.CreateFlipped(meta, reader.Format, reader.Palette, reader.Data, reader.Stride)); }
public override ImageData Read(Stream stream, ImageMetaData info) { var meta = (GyuMetaData)info; if (0 == meta.Key) { throw new UnknownEncryptionScheme("Unknown image encryption key"); } var reader = new GyuReader(stream, meta); reader.Unpack(); return(ImageData.CreateFlipped(meta, reader.Format, reader.Palette, reader.Data, reader.Stride)); }
public override ImageData Read(IBinaryStream stream, ImageMetaData info) { var meta = (GyuMetaData)info; if (0 == meta.Key) { object token = null; if (null == CurrentMap) { CurrentMap = QueryScheme(); } if (CurrentMap != null) { var name = Path.GetFileNameWithoutExtension(meta.FileName); int num; if (int.TryParse(name, out num) && CurrentMap.Contains(num)) { token = num; } else if (CurrentMap.Contains(name)) { token = name; } } if (null == token) { CurrentMap = null; throw new UnknownEncryptionScheme("Unknown image encryption key"); } meta.Key = (uint)CurrentMap[token]; } var reader = new GyuReader(stream.AsStream, meta); reader.Unpack(); return(ImageData.CreateFlipped(meta, reader.Format, reader.Palette, reader.Data, reader.Stride)); }