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 
) [inline]

Constructor.

Parameters:
img The targa image we're loading.
up_down Tell if the image is stored from top to bottom.
left_right Tell 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().

00088   : m_image(img), m_x_inc(left_right ? 1 : -1), m_y_inc(up_down ? 1 : -1)
00089 {
00090   if (up_down)
00091     m_y = 0;
00092   else
00093     m_y = m_image.height() - 1;
00094 
00095   if (left_right)
00096     m_x = 0;
00097   else
00098     m_x = m_image.width() - 1;
00099 } // 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  )  [inline, private]

Recalculate the position in the file.

Parameters:
x The 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::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, claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::m_y_inc, and claw::graphic::image::width().

00169 {
00170   if (x < 0)
00171     {
00172       m_x = m_image.width() - 1;
00173       m_y += m_y_inc;
00174     }
00175   else if (x >= (int)m_image.width())
00176     {
00177       m_x = 0;
00178       m_y += m_y_inc;
00179     }
00180   else
00181     m_x = x;
00182 } // targa::reader::rle_targa_output_buffer::adjust_position()

template<typename InputBuffer >
bool claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::completed (  )  const [inline]

Tell if we have completely filled the image.

Definition at line 151 of file targa_reader.tpp.

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

00152 {
00153   return ( (int)m_y == -1 ) || ( m_y == m_image.height() );
00154 } // 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 
) [inline]

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

Parameters:
n The number of pixels to write.
buffer The 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().

00132 {
00133   assert( (int)(m_x + m_x_inc * n) >= -1 );
00134   assert( m_x + m_x_inc * n <= m_image.width() );
00135 
00136   const int bound = (int)m_x + m_x_inc * n;
00137   int x = m_x;
00138 
00139   for ( ; x != bound; x += m_x_inc )
00140     m_image[m_y][x] = buffer.get_pixel();
00141 
00142   adjust_position(x);
00143 } // 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 
) [inline]

Copy a pixel a certain number of times.

Parameters:
n The number of pixel to write.
pattern The pixel to copy.

Definition at line 109 of file targa_reader.tpp.

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

00110 {
00111   assert( (int)(m_x + m_x_inc * n) >= -1 );
00112   assert( m_x + m_x_inc * n <= m_image.width() );
00113 
00114   const int bound = (int)m_x + m_x_inc * n;
00115   int x = m_x;
00116 
00117   for ( ; x != bound; x += m_x_inc )
00118     m_image[m_y][x] = pattern;
00119 
00120   adjust_position(x);
00121 } // 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]
template<typename InputBuffer>
unsigned int claw::graphic::targa::reader::rle_targa_output_buffer< InputBuffer >::m_x [private]
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]
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.

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


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

Generated on 9 Nov 2009 for CLAW Library (a C++ Library Absolutely Wonderful) by  doxygen 1.6.1