Esempio n. 1
0
 public Reader(IBinaryStream input, Pt1MetaData info)
 {
     m_type         = info.Type;
     m_input        = new byte[info.PackedSize + 8];
     input.Position = 0x20;
     if (info.PackedSize != input.Read(m_input, 0, info.PackedSize))
     {
         throw new InvalidFormatException("Unexpected end of file");
     }
     m_width  = (int)info.Width;
     m_height = (int)info.Height;
     m_output = new byte[info.UnpackedSize];
     m_stride = m_width * 3;
     if (3 == m_type)
     {
         Format = PixelFormats.Bgra32;
         int packed_size = input.ReadInt32();
         m_alpha_packed = input.ReadBytes(packed_size);
         if (m_alpha_packed.Length != packed_size)
         {
             throw new EndOfStreamException();
         }
     }
     else
     {
         Format = PixelFormats.Bgr24;
     }
 }
Esempio n. 2
0
 public Reader(Stream input, Pt1MetaData info)
 {
     m_type         = info.Type;
     m_input        = new byte[info.PackedSize + 8];
     input.Position = 0x20;
     if ((int)info.PackedSize != input.Read(m_input, 0, (int)info.PackedSize))
     {
         throw new InvalidFormatException("Unexpected end of file");
     }
     m_width  = (int)info.Width;
     m_height = (int)info.Height;
     m_output = new byte[info.UnpackedSize];
     m_stride = m_width * 3;
     if (3 == m_type)
     {
         Format = PixelFormats.Bgra32;
         using (var reader = new ArcView.Reader(input))
         {
             int packed_size = reader.ReadInt32();
             m_alpha_packed = new byte[packed_size];
             if (packed_size != input.Read(m_alpha_packed, 0, packed_size))
             {
                 throw new EndOfStreamException();
             }
         }
     }
     else
     {
         Format = PixelFormats.Bgr24;
     }
 }