예제 #1
0
 public override ImageMetaData ReadMetaData(IBinaryStream file)
 {
     using (var lzs = new LzssStream(file.AsStream, LzssMode.Decompress, true))
     {
         if (lzs.ReadByte() != 'B' || lzs.ReadByte() != 'M')
         {
             return(null);
         }
         var bmp = new byte[0x26];
         if (0x24 != lzs.Read(bmp, 2, 0x24))
         {
             return(null);
         }
         int file_size  = LittleEndian.ToInt32(bmp, 2);
         int width      = LittleEndian.ToInt32(bmp, 0x12);
         int height     = LittleEndian.ToInt32(bmp, 0x16);
         int bpp        = LittleEndian.ToInt16(bmp, 0x1C);
         int image_size = LittleEndian.ToInt32(bmp, 0x22);
         if (0 == image_size)
         {
             image_size = width * height * (bpp / 8);
         }
         return(new GrMetaData
         {
             Width = (uint)width,
             Height = (uint)height,
             BPP = bpp,
             UnpackedSize = 24 == bpp ? file_size : (image_size + 0x36),
         });
     }
 }