示例#1
0
文件: ArcPAK.cs 项目: zxc120/GARbro
        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));
        }
示例#2
0
文件: ArcUCA.cs 项目: zxc120/GARbro
        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));
        }
示例#3
0
        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));
        }
示例#4
0
        public override IImageDecoder OpenImage(ArcFile arc, Entry entry)
        {
            var input = arc.File.CreateStream(entry.Offset, entry.Size);
            var info  = CgdMetaData.FromStream(input, 0);

            input.Position = 0;
            if (null == info)
            {
                return(ImageFormatDecoder.Create(input));
            }
            return(new CgdDecoder(input, info));
        }
示例#5
0
文件: ArcFG.cs 项目: zxc120/GARbro
        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));
        }
示例#6
0
文件: ArcSWF.cs 项目: ziyuejun/GARbro
        IImageDecoder OpenBitsJpeg(SwfChunk chunk)
        {
            int jpeg_pos = 0;

            for (int i = 0; i < chunk.Data.Length - 2; ++i)
            {
                if (chunk.Data[i] == 0xFF && chunk.Data[i + 1] == 0xD8)
                {
                    jpeg_pos = i;
                    break;
                }
            }
            var input = new BinMemoryStream(chunk.Data, jpeg_pos, chunk.Data.Length - jpeg_pos);

            return(ImageFormatDecoder.Create(input));
        }
示例#7
0
        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));
        }
示例#8
0
        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));
        }
示例#9
0
        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));
        }