public override IImageDecoder OpenImage(ArcFile arc, Entry entry) { var barc = arc as BellArchive; if (null == barc || entry.Size < 5) { return(base.OpenImage(arc, entry)); } var input = arc.OpenBinaryEntry(entry); try { var reader = DecryptImage(input, barc.Scheme); if (BlendOverlayImages) { var overlay = reader as AImageReader; if (overlay != null) { overlay.ReadBaseline(barc, entry); } } return(reader); } catch { input.Dispose(); throw; } }
public override IImageDecoder OpenImage(ArcFile arc, Entry entry) { if (!entry.Name.HasExtension(".tga")) { return(base.OpenImage(arc, entry)); } var input = arc.OpenBinaryEntry(entry); try { var header = input.ReadHeader(18); if (0 == header[16]) { header[16] = 32; } if (0 == header[17] && 32 == header[16]) { header[17] = 8; } Stream tga_input = new StreamRegion(input.AsStream, 18); tga_input = new PrefixStream(header.ToArray(), tga_input); var tga = new BinaryStream(tga_input, entry.Name); var info = ImageFormat.Tga.ReadMetaData(tga); if (info != null) { tga.Position = 0; return(new ImageFormatDecoder(tga, ImageFormat.Tga, info)); } } catch { /* ignore errors */ } input.Position = 0; return(ImageFormatDecoder.Create(input)); }
public override IImageDecoder OpenImage(ArcFile arc, Entry entry) { var sarc = arc as SeraphArchive; var aent = entry as ArchEntry; if (null == sarc || null == aent || null == sarc.EventMap || aent.DirIndex != sarc.EventDir || !sarc.EventMap.ContainsKey(aent.FileIndex)) { return(OpenRawImage(arc, entry)); } var base_index = sarc.EventMap[aent.FileIndex]; var base_entry = sarc.Dir.Cast <ArchEntry>() .FirstOrDefault(e => e.DirIndex == sarc.EventDir && e.FileIndex == base_index); if (null == base_entry) { return(base.OpenImage(arc, entry)); } var base_img = OpenCtImage(arc, base_entry); if (null == base_img) { return(base.OpenImage(arc, entry)); } var input = arc.OpenBinaryEntry(entry); return(new CtOverlayDecoder(input, base_img)); }
IImageDecoder OpenRawImage(ArcFile arc, Entry entry) { var input = arc.OpenBinaryEntry(entry); try { uint width = input.ReadUInt16(); uint height = input.ReadUInt16(); if (width > 0x4100 || 0 == width || 0 == height || width * height * 3 + 4 != input.Length) { input.Position = 0; return(new ImageFormatDecoder(input)); } else { var info = new ImageMetaData { Width = width, Height = height, BPP = 24 }; return(new RawBitmapDecoder(input, info)); } } catch { input.Dispose(); throw; } }
public override IImageDecoder OpenImage(ArcFile arc, Entry entry) { var pent = (PcdEntry)entry; var input = arc.OpenBinaryEntry(entry); return(new PsdFormatDecoder(input, pent)); }
public override IImageDecoder OpenImage(ArcFile arc, Entry entry) { var input = arc.OpenBinaryEntry(entry); if (0x28 == input.Signature) { return(new UcaBitmapDecoder(input)); } return(ImageFormatDecoder.Create(input)); }
public override IImageDecoder OpenImage(ArcFile arc, Entry entry) { var input = arc.OpenBinaryEntry(entry); if (input.Length <= 8 || input.Signature != 0x58474D49) // 'IMGX' { return(ImageFormatDecoder.Create(input)); } return(new ImgXDecoder(input)); }
void ExtractAudio(ArcFile arc, Entry entry) { using (var file = arc.OpenBinaryEntry(entry)) using (var sound = AudioFormat.Read(file)) { if (sound == null) { throw new InvalidFormatException("Unable to interpret audio format"); } ConvertAudio(entry.Name, sound); } }
public override IImageDecoder OpenImage(ArcFile arc, Entry entry) { if (entry is VirtualCharEntry) { return(BlendEntry(arc, entry as VirtualCharEntry)); } var input = arc.OpenBinaryEntry(entry); var info = ImageFormat.Png.ReadMetaData(input); input.Position = 0; return(new ImageFormatDecoder(input, ImageFormat.Png, info)); }
void ExtractAudio(ArcFile arc, Entry entry) { using (var file = arc.OpenBinaryEntry(entry)) using (var sound = AudioFormat.Read(file)) { if (null == sound) { throw new InvalidFormatException(guiStrings.MsgUnableInterpretAudio); } ConvertAudio(entry.Name, sound); } }
public override IImageDecoder OpenImage(ArcFile arc, Entry entry) { var fgent = (FgEntry)entry; var input = arc.OpenBinaryEntry(entry); var bmp_info = ImageFormat.Bmp.ReadMetaData(input); input.Position = 0; if (null == bmp_info) { return(ImageFormatDecoder.Create(input)); } bmp_info.OffsetX = fgent.Info.OffsetX; bmp_info.OffsetY = fgent.Info.OffsetY; return(new ImageFormatDecoder(input, ImageFormat.Bmp, bmp_info)); }
SeraphReader OpenCtImage(ArcFile arc, Entry entry) { using (var input = arc.OpenBinaryEntry(entry)) { if (input.Signature != CtFormat.Value.Signature) { return(null); } var info = CtFormat.Value.ReadMetaData(input) as SeraphMetaData; if (null == info) { return(null); } var reader = new SeraphReader(input.AsStream, info); reader.UnpackCt(); return(reader); } }
public override IImageDecoder OpenImage(ArcFile arc, Entry entry) { var input = arc.OpenBinaryEntry(entry); int fmt = (int)input.Signature & 0xFFFF; if (fmt > 4) { return(ImageFormatDecoder.Create(input)); } var header = input.ReadHeader(14); input.Position = 0; int hpos = 2; if (1 == fmt || 3 == fmt) { hpos = 8; } int cmp = header.ToUInt16(hpos); int bpp = 0; switch (cmp & 0xFF) { case 2: bpp = 4; break; case 3: bpp = 8; break; case 5: bpp = 24; break; default: return(ImageFormatDecoder.Create(input)); } var info = new LcImageMetaData { Width = header.ToUInt16(hpos + 2), Height = header.ToUInt16(hpos + 4), BPP = bpp, Format = fmt, Compression = cmp, DataOffset = hpos + 6, }; return(new LcImageDecoder(input, info)); }
public override IImageDecoder OpenImage(ArcFile arc, Entry entry) { var input = arc.OpenBinaryEntry(entry); int length = (int)(input.Length - 0x10); if ((length & 3) != 0) { return(ImageFormatDecoder.Create(input)); } uint width = input.ReadUInt32(); uint height = input.ReadUInt32(); int buf_width = input.ReadInt32(); int buf_height = input.ReadInt32(); var info = new ImageMetaData { Width = width, Height = height, BPP = 32 }; return(new Gx4ImageDecoder(input, info)); }
public override IImageDecoder OpenImage(ArcFile arc, Entry entry) { var input = arc.OpenBinaryEntry(entry); int length = (int)(input.Length - 0x10); if ((length & 3) != 0) { return(ImageFormatDecoder.Create(input)); } uint width = input.ReadUInt32(); uint height = input.ReadUInt32(); int buf_width = input.ReadInt32(); int buf_height = input.ReadInt32(); var info = new ImageMetaData { Width = width, Height = height, BPP = 32 }; if (DefaultVisualMap.Value.ContainsKey(entry.Name)) { var diff_info = DefaultVisualMap.Value[entry.Name]; if (VFS.FileExists(diff_info.BaseFileName)) { var base_entry = VFS.FindFile(diff_info.BaseFileName); using (var visbase = VFS.OpenImage(base_entry)) { var base_decoder = visbase as Gx4ImageDecoder; if (base_decoder != null) { info.OffsetX = diff_info.PosX; info.OffsetY = diff_info.PosY; var pixels = base_decoder.ReadPixels(); return(new Gx4OverlayDecoder(pixels, base_decoder.Info, input, info)); } } } } return(new Gx4ImageDecoder(input, info)); }