Exemple #1
0
        public override ImageMetaData ReadMetaData(IBinaryStream file)
        {
            var  info           = new AkbMetaData();
            bool is_incremental = '+' == (file.ReadUInt32() >> 24);

            info.Width       = file.ReadUInt16();
            info.Height      = file.ReadUInt16();
            info.Flags       = file.ReadUInt32();
            info.BPP         = 0 == (info.Flags & 0x40000000) ? 32 : 24;
            info.Background  = file.ReadBytes(4);
            info.OffsetX     = file.ReadInt32();
            info.OffsetY     = file.ReadInt32();
            info.InnerWidth  = file.ReadInt32() - info.OffsetX;
            info.InnerHeight = file.ReadInt32() - info.OffsetY;
            if (info.InnerWidth > info.Width || info.InnerHeight > info.Height)
            {
                return(null);
            }
            if (is_incremental)
            {
                info.BaseFileName = file.ReadCString(0x20);
            }
            info.DataOffset = (uint)file.Position;
            return(info);
        }
Exemple #2
0
        byte[] ReadBaseImage(string filename, AkbMetaData overlay_info)
        {
            var pattern = Path.GetFileNameWithoutExtension(filename) + ".*";

            pattern = VFS.CombinePath(VFS.GetDirectoryName(filename), pattern);
            foreach (var entry in VFS.GetFiles(pattern))
            {
                if (entry.Name == overlay_info.FileName)
                {
                    continue;
                }
                using (var base_file = VFS.OpenBinaryStream(entry))
                {
                    var base_info = ReadMetaData(base_file) as AkbMetaData;
                    if (null != base_info && base_info.BPP == overlay_info.BPP &&
                        base_info.Width == overlay_info.Width && base_info.Height == overlay_info.Height)
                    {
                        // FIXME what if baseline image is incremental itself?
                        var reader = new AkbReader(base_file.AsStream, base_info);
                        return(reader.Unpack());
                    }
                }
            }
            return(null);
        }
Exemple #3
0
 public AkbReader(Stream input, AkbMetaData info)
 {
     m_input      = input;
     m_info       = info;
     m_pixel_size = m_info.BPP / 8;
     Stride       = (int)m_info.Width * m_pixel_size;
     Format       = 24 == m_info.BPP ? PixelFormats.Bgr24 : PixelFormats.Bgra32;
 }
Exemple #4
0
 public AkbReader(Stream input, AkbMetaData info)
 {
     m_input      = input;
     m_info       = info;
     m_pixel_size = m_info.BPP / 8;
     Stride       = (int)m_info.Width * m_pixel_size;
     if (24 == m_info.BPP)
     {
         Format = PixelFormats.Bgr24;
     }
     else if (0 == (m_info.Flags & 0x80000000))
     {
         Format = PixelFormats.Bgr32;
     }
     else
     {
         Format = PixelFormats.Bgra32;
     }
 }
Exemple #5
0
 public override ImageMetaData ReadMetaData(Stream stream)
 {
     using (var reader = new ArcView.Reader (stream))
     {
         reader.ReadInt32();
         var info = new AkbMetaData();
         info.Width = reader.ReadUInt16();
         info.Height = reader.ReadUInt16();
         int flags = reader.ReadInt32() & 0xFFFF;
         info.BPP = 0 == flags ? 32 : 24;
         info.Background = reader.ReadBytes (4);
         info.OffsetX = reader.ReadInt32();
         info.OffsetY = reader.ReadInt32();
         info.InnerWidth = reader.ReadInt32() - info.OffsetX;
         info.InnerHeight = reader.ReadInt32() - info.OffsetY;
         if (info.InnerWidth > info.Width || info.InnerHeight > info.Height)
             return null;
         return info;
     }
 }
Exemple #6
0
        }                                                                 // 'AKB '

        public override ImageMetaData ReadMetaData(Stream stream)
        {
            using (var reader = new ArcView.Reader(stream))
            {
                reader.ReadInt32();
                var info = new AkbMetaData();
                info.Width  = reader.ReadUInt16();
                info.Height = reader.ReadUInt16();
                int flags = reader.ReadInt32() & 0xFFFF;
                info.BPP         = 0 == flags ? 32 : 24;
                info.Background  = reader.ReadBytes(4);
                info.OffsetX     = reader.ReadInt32();
                info.OffsetY     = reader.ReadInt32();
                info.InnerWidth  = reader.ReadInt32() - info.OffsetX;
                info.InnerHeight = reader.ReadInt32() - info.OffsetY;
                if (info.InnerWidth > info.Width || info.InnerHeight > info.Height)
                {
                    return(null);
                }
                return(info);
            }
        }
Exemple #7
0
 public AkbReader(Stream input, AkbMetaData info)
 {
     m_input = input;
     m_info = info;
     m_pixel_size = m_info.BPP / 8;
     Stride = (int)m_info.Width * m_pixel_size;
     Format = 24 == m_info.BPP ? PixelFormats.Bgr24 : PixelFormats.Bgra32;
 }