CLAW Library (a C++ Library Absolutely Wonderful) 1.5.5
Public Member Functions | Private Attributes
claw::graphic::gif::reader::output_buffer Class Reference

Buffer passed to the LZW decoder to write decoded data. More...

List of all members.

Public Member Functions

 output_buffer (const palette_type &p, const image_descriptor &id, int transparent_color_index, image &output)
 Constructor.
void write (unsigned int code)
 Write a data.

Private Attributes

const palette_typem_palette
 The palette from whick we take the colors of the image.
const image_descriptorm_id
 The image descriptor of the frame.
const int m_transparent_color_index
 The index of the transparent color. -1 if none.
imagem_output
 The image in which we save the decoded data.
std::size_t m_x
 The x-position of the next pixel in the image.
std::size_t m_y
 The y-position of the next pixel in the image.
int m_interlace_pass
 Current pass in an interlaced image [0-3].
int m_interlace_step
 Increment in the current pass of an interlaced image.

Detailed Description

Buffer passed to the LZW decoder to write decoded data.

Definition at line 359 of file gif.hpp.


Constructor & Destructor Documentation

claw::graphic::gif::reader::output_buffer::output_buffer ( const palette_type p,
const image_descriptor id,
int  transparent_color_index,
image output 
)

Constructor.

Parameters:
pThe palette from which we take the color.
idThe descriptor of the frame.
transparent_color_indexThe index of the transparent color in p.
outputThe image in which we store the data.

Definition at line 212 of file gif_reader.cpp.

  : m_palette(p), m_id(id), m_transparent_color_index(transparent_color_index),
    m_output(output), m_x(0), m_y(0), m_interlace_pass(0),
    m_interlace_step(8)
{

} // gif::reader::output_buffer::output_buffer()

Member Function Documentation

void claw::graphic::gif::reader::output_buffer::write ( unsigned int  code)

Write a data.

Parameters:
codeThe data to write.

Definition at line 226 of file gif_reader.cpp.

{
  assert(code < m_palette.size());
  assert(m_x < m_id.width);
  assert(m_y < m_id.height);

  m_output[m_y + m_id.top][m_x + m_id.left] = m_palette[code];

  if ( m_transparent_color_index != -1 )
    if ( code == (unsigned int)m_transparent_color_index )
      m_output[m_y + m_id.top][m_x + m_id.left].components.alpha = 0;

  ++m_x;

  if (m_x == m_id.width)
    {
      m_x = 0;

      if ( !m_id.is_interlaced() )
        ++m_y;
      else
        {
          m_y += m_interlace_step;

          while ( (m_y >= m_id.height) && (m_interlace_pass!=3) )
            {
              ++m_interlace_pass;
              switch (m_interlace_pass)
                {
                case 1: m_y = 4; m_interlace_step = 8; break;
                case 2: m_y = 2; m_interlace_step = 4; break;
                case 3: m_y = 1; m_interlace_step = 2; break;
                }
            }
        }
    }
} // gif::reader::output_buffer::write()

Member Data Documentation

The image descriptor of the frame.

Definition at line 373 of file gif.hpp.

Current pass in an interlaced image [0-3].

Definition at line 388 of file gif.hpp.

Increment in the current pass of an interlaced image.

Definition at line 391 of file gif.hpp.

The image in which we save the decoded data.

Definition at line 379 of file gif.hpp.

The palette from whick we take the colors of the image.

Definition at line 370 of file gif.hpp.

The index of the transparent color. -1 if none.

Definition at line 376 of file gif.hpp.

The x-position of the next pixel in the image.

Definition at line 382 of file gif.hpp.

The y-position of the next pixel in the image.

Definition at line 385 of file gif.hpp.


The documentation for this class was generated from the following files: