CLAW Library (a C++ Library Absolutely Wonderful) 1.5.5
Public Member Functions | Private Types | Private Member Functions | Private Attributes
claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer > Class Template Reference

The output buffer for the RLE decoder. More...

List of all members.

Public Member Functions

 rle_targa_output_buffer (image &img, bool up_down, bool left_right)
 Constructor.
void fill (unsigned int n, rgba_pixel_8 pattern)
 Copy a pixel a certain number of times.
void copy (unsigned int n, input_buffer_type &buffer)
 Direct copy of a certain number of pixels from the file.
bool completed () const
 Tell if we have completely filled the image.

Private Types

typedef rgba_pixel_8 pixel_type
 The type of he pixels in the input buffer.
typedef InputBuffer input_buffer_type
 The type of the input buffer.

Private Member Functions

void adjust_position (int x)
 Recalculate the position in the file.

Private Attributes

imagem_image
 The targa image to fill.
unsigned int m_x
 Current column index in the image.
unsigned int m_y
 Current row index in the image.
const int m_x_inc
 Horizontal increment.
const int m_y_inc
 Vertical increment.

Detailed Description

template<typename InputBuffer>
class claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >

The output buffer for the RLE decoder.

Template parameters

Author:
Julien Jorge

Definition at line 273 of file targa.hpp.


Member Typedef Documentation

template<typename InputBuffer>
typedef InputBuffer claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::input_buffer_type [private]

The type of the input buffer.

Definition at line 280 of file targa.hpp.

template<typename InputBuffer>
typedef rgba_pixel_8 claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::pixel_type [private]

The type of he pixels in the input buffer.

Definition at line 277 of file targa.hpp.


Constructor & Destructor Documentation

template<typename InputBuffer >
claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::rle_targa_output_buffer ( image img,
bool  up_down,
bool  left_right 
)

Constructor.

Parameters:
imgThe targa image we're loading.
up_downTell if the image is stored from top to bottom.
left_rightTell if the image is stored from left to right.

Definition at line 87 of file targa_reader.tpp.

References claw::graphic::image::height(), claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::m_image, claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::m_x, claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::m_y, and claw::graphic::image::width().

  : m_image(img), m_x_inc(left_right ? 1 : -1), m_y_inc(up_down ? 1 : -1)
{
  if (up_down)
    m_y = 0;
  else
    m_y = m_image.height() - 1;

  if (left_right)
    m_x = 0;
  else
    m_x = m_image.width() - 1;
} // targa::reader::rle_targa_output_buffer::rle_targa_output_buffer()

Member Function Documentation

template<typename InputBuffer >
void claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::adjust_position ( int  x) [private]

Recalculate the position in the file.

Parameters:
xThe x-coordinate where we stopped.

If x is lower tha zero, the position is set at the end of the previous line ; if is greater or equal to the width of the image, the position is set at the begining of the next line ; otherwise the position is set to x.

Definition at line 168 of file targa_reader.tpp.

References claw::graphic::targa::reader::m_image, and claw::graphic::image::width().

{
  if (x < 0)
    {
      m_x = m_image.width() - 1;
      m_y += m_y_inc;
    }
  else if (x >= (int)m_image.width())
    {
      m_x = 0;
      m_y += m_y_inc;
    }
  else
    m_x = x;
} // targa::reader::rle_targa_output_buffer::adjust_position()
template<typename InputBuffer >
bool claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::completed ( ) const

Tell if we have completely filled the image.

Definition at line 151 of file targa_reader.tpp.

References claw::graphic::image::height(), and claw::graphic::targa::reader::m_image.

{
  return ( (int)m_y == -1 ) || ( m_y == m_image.height() );
} // targa::reader::rle_targa_output_buffer::completed()
template<typename InputBuffer >
void claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::copy ( unsigned int  n,
input_buffer_type buffer 
)

Direct copy of a certain number of pixels from the file.

Parameters:
nThe number of pixels to write.
bufferThe buffer from which we read.

Definition at line 131 of file targa_reader.tpp.

References claw::graphic::targa::reader::m_image, and claw::graphic::image::width().

{
  assert( (int)(m_x + m_x_inc * n) >= -1 );
  assert( m_x + m_x_inc * n <= m_image.width() );

  const int bound = (int)m_x + m_x_inc * n;
  int x = m_x;

  for ( ; x != bound; x += m_x_inc )
    m_image[m_y][x] = buffer.get_pixel();

  adjust_position(x);
} // targa::reader::rle_targa_output_buffer::copy()
template<typename InputBuffer >
void claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::fill ( unsigned int  n,
rgba_pixel_8  pattern 
)

Copy a pixel a certain number of times.

Parameters:
nThe number of pixel to write.
patternThe pixel to copy.

Definition at line 109 of file targa_reader.tpp.

References claw::graphic::targa::reader::m_image, and claw::graphic::image::width().

{
  assert( (int)(m_x + m_x_inc * n) >= -1 );
  assert( m_x + m_x_inc * n <= m_image.width() );

  const int bound = (int)m_x + m_x_inc * n;
  int x = m_x;

  for ( ; x != bound; x += m_x_inc )
    m_image[m_y][x] = pattern;

  adjust_position(x);
} // targa::reader::rle_targa_output_buffer::fill()

Member Data Documentation

template<typename InputBuffer>
image& claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::m_image [private]

The targa image to fill.

Definition at line 295 of file targa.hpp.

Referenced by claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::rle_targa_output_buffer().

template<typename InputBuffer>
unsigned int claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::m_x [private]

Current column index in the image.

Definition at line 298 of file targa.hpp.

Referenced by claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::rle_targa_output_buffer().

template<typename InputBuffer>
const int claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::m_x_inc [private]

Horizontal increment.

Definition at line 304 of file targa.hpp.

template<typename InputBuffer>
unsigned int claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::m_y [private]

Current row index in the image.

Definition at line 301 of file targa.hpp.

Referenced by claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::rle_targa_output_buffer().

template<typename InputBuffer>
const int claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::m_y_inc [private]

Vertical increment.

Definition at line 307 of file targa.hpp.


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