Exemple #1
0
void istream_read_mdcXyzNormal(PointerInputStream& inputStream, mdcXyzNormal_t& xyz)
{
  xyz.xyz[0] = istream_read_int16_le(inputStream);
  xyz.xyz[1] = istream_read_int16_le(inputStream);
  xyz.xyz[2] = istream_read_int16_le(inputStream);
  xyz.normal = istream_read_int16_le(inputStream);
}
Exemple #2
0
void istream_read_md2Triangle( PointerInputStream& inputStream, md2Triangle_t& triangle ){
	triangle.index_xyz[0] = istream_read_int16_le( inputStream );
	triangle.index_xyz[1] = istream_read_int16_le( inputStream );
	triangle.index_xyz[2] = istream_read_int16_le( inputStream );
	triangle.index_st[0] = istream_read_int16_le( inputStream );
	triangle.index_st[1] = istream_read_int16_le( inputStream );
	triangle.index_st[2] = istream_read_int16_le( inputStream );
}
Exemple #3
0
inline void targa_header_read_istream(TargaHeader& targa_header, PointerInputStream& istream)
{
  targa_header.id_length = istream_read_byte(istream);
  targa_header.colormap_type = istream_read_byte(istream);
  targa_header.image_type = istream_read_byte(istream);

  targa_header.colormap_index = istream_read_int16_le(istream);
  targa_header.colormap_length = istream_read_int16_le(istream);
  targa_header.colormap_size = istream_read_byte(istream);
  targa_header.x_origin = istream_read_int16_le(istream);
  targa_header.y_origin = istream_read_int16_le(istream);
  targa_header.width = istream_read_int16_le(istream);
  targa_header.height = istream_read_int16_le(istream);
  targa_header.pixel_size = istream_read_byte(istream);
  targa_header.attributes = istream_read_byte(istream);

  if (targa_header.id_length != 0)
    istream.seek(targa_header.id_length);	// skip TARGA image comment
}
Exemple #4
0
void LoadPCXBuff(byte* buffer, std::size_t len, byte **pic, byte **palette, int *width, int *height )
{
  *pic = 0;

  pcx_t	pcx;
  int		x, y, lsize;
  byte	*out, *pix;

  /* parse the PCX file */

  PointerInputStream inputStream(buffer);

  pcx.manufacturer = istream_read_byte(inputStream);
  pcx.version = istream_read_byte(inputStream);
  pcx.encoding = istream_read_byte(inputStream);
  pcx.bits_per_pixel = istream_read_byte(inputStream);
  pcx.xmin = istream_read_int16_le(inputStream);
  pcx.ymin = istream_read_int16_le(inputStream);
  pcx.xmax = istream_read_int16_le(inputStream);
  pcx.ymax = istream_read_int16_le(inputStream);
  pcx.hres = istream_read_int16_le(inputStream);
  pcx.vres = istream_read_int16_le(inputStream);
  inputStream.read(pcx.palette, 48);
  pcx.reserved = istream_read_byte(inputStream);
  pcx.color_planes = istream_read_byte(inputStream);
  pcx.bytes_per_line = istream_read_int16_le(inputStream);
  pcx.palette_type = istream_read_int16_le(inputStream);
  inputStream.read(pcx.filler, 58);


  if (pcx.manufacturer != 0x0a
    || pcx.version != 5
    || pcx.encoding != 1
    || pcx.bits_per_pixel != 8)
    return;

  if (width)
    *width = pcx.xmax+1;
  if (height)
    *height = pcx.ymax+1;

  if (!pic)
    return;

  out = (byte *)malloc ( (pcx.ymax+1) * (pcx.xmax+1) );

  *pic = out;
  pix = out;

  /* RR2DO2: pcx fix  */
  lsize = pcx.color_planes * pcx.bytes_per_line;

  /* go scanline by scanline */
  for( y = 0; y <= pcx.ymax; y++, pix += pcx.xmax + 1 )
  {
    /* do a scanline */
    for( x=0; x <= pcx.xmax; )
    {
      /* RR2DO2 */
      PCXRLEPacket packet;
      ByteStream_readPCXRLEPacket(inputStream, packet);

      while(packet.length-- > 0)
      {
        pix[ x++ ] = packet.data;
      }
    }

    /* RR2DO2: discard any other data */
    PCXRLEPacket packet;
    while( x < lsize )
    {
      ByteStream_readPCXRLEPacket(inputStream, packet);
      x++;
    }
    while( packet.length-- > 0 )
    {
      x++;
    }
  }

  /* validity check */
  if( std::size_t(inputStream.get() - buffer) > len)
  {
    *pic = 0;
  }

  if (palette)
  {
    *palette = (byte *)malloc(768);
    memcpy (*palette, buffer + len - 768, 768);
  }
}
Exemple #5
0
void istream_read_md2St( PointerInputStream& inputStream, md2St_t& st ){
	st.s = istream_read_int16_le( inputStream );
	st.t = istream_read_int16_le( inputStream );
}