claw::graphic::bitmap::reader::rle_bitmap_output_buffer< Coded4bits > Class Template Reference

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

List of all members.

Public Member Functions

 rle_bitmap_output_buffer (const color_palette_type &palette, image &image)
 Constructor.
void fill (unsigned int n, unsigned char pattern)
void copy (unsigned int n, file_input_buffer &buffer)
void next_line ()
 Go to the begining of the next line to fill.
void delta_move (unsigned char x, unsigned char y)
 Move the cursor horizontally and vertically.
template<>
void fill (unsigned int n, unsigned char pattern)
template<>
void fill (unsigned int n, unsigned char pattern)
template<>
void copy (unsigned int n, file_input_buffer &buffer)
template<>
void copy (unsigned int n, file_input_buffer &buffer)

Private Attributes

const color_palette_typem_palette
 Color palette.
imagem_image
 The image to fill.
unsigned int m_x
 Current column index in the bitmap.
unsigned int m_y
 Current row index in the bitmap.

Detailed Description

template<bool Coded4bits>
class claw::graphic::bitmap::reader::rle_bitmap_output_buffer< Coded4bits >

The output buffer for the RLE decoder.

Template parameters

Author:
Julien Jorge

Definition at line 152 of file bitmap.hpp.


Constructor & Destructor Documentation

template<bool Coded4Bits>
claw::graphic::bitmap::reader::rle_bitmap_output_buffer< Coded4Bits >::rle_bitmap_output_buffer ( const color_palette_type palette,
image img 
) [inline]

Constructor.

Parameters:
palette The color palette to convert the pixels.
img The image we're filling.

Definition at line 43 of file bitmap_reader.tpp.

00044   : m_palette(palette), m_image(img), m_x(0), m_y(m_image.height() - 1)
00045 {
00046 
00047 } // bitmap::reader::rle_bitmap_output_buffer::rle_bitmap_output_buffer()


Member Function Documentation

template<>
void claw::graphic::bitmap::reader::rle_bitmap_output_buffer< true >::copy ( unsigned int  n,
file_input_buffer buffer 
) [inline]
Parameters:
n The number of pixels to copy.
buffer The input buffer, to copy from.
Remarks:
This method is for 4bpp bitmaps.

Definition at line 139 of file bitmap_reader.cpp.

References claw::buffered_istream< Stream >::get_buffer(), claw::buffered_istream< Stream >::move(), claw::buffered_istream< Stream >::read_more(), and claw::buffered_istream< Stream >::remaining().

00140     {
00141       assert( m_x + n <= m_image.width() );
00142 
00143       // RLE bitmap data is 2-bytes aligned
00144       unsigned int bytes_needed = n / 2 + n % 2;
00145 
00146       if ( bytes_needed % 2 )
00147         ++bytes_needed;
00148 
00149       if ( buffer.remaining() < bytes_needed )
00150         buffer.read_more( bytes_needed );
00151 
00152       assert( buffer.remaining() >= bytes_needed );
00153 
00154       const unsigned char* p =
00155         reinterpret_cast<const unsigned char*>(buffer.get_buffer());
00156       const unsigned char* last = p + n / 2;
00157 
00158       for ( ; p != last; ++p, m_x += 2)
00159         {
00160           m_image[m_y][m_x] = m_palette[ (*p & 0xF0) >> 4 ];
00161           m_image[m_y][m_x+1] = m_palette[ *p & 0x0F ];
00162         }
00163 
00164       if ( n % 2 )
00165         {
00166           m_image[m_y][m_x] = m_palette[ (*p & 0xF0) >> 4 ];
00167           ++m_x;
00168         }
00169 
00170       buffer.move( bytes_needed );
00171     } // bitmap::reader::rle_bitmap_output_buffer<true>::copy()

template<>
void claw::graphic::bitmap::reader::rle_bitmap_output_buffer< false >::copy ( unsigned int  n,
file_input_buffer buffer 
) [inline]
Parameters:
n The number of pixels to copy.
buffer The input buffer, to copy from.
Remarks:
This method is for 8bpp bitmaps.

Definition at line 102 of file bitmap_reader.cpp.

References claw::buffered_istream< Stream >::get_buffer(), claw::buffered_istream< Stream >::move(), claw::buffered_istream< Stream >::read_more(), and claw::buffered_istream< Stream >::remaining().

00103     {
00104       assert( m_x + n <= m_image.width() );
00105       
00106       // RLE bitmap data is 2-bytes aligned
00107       const unsigned int bytes_needed = n + n % 2;
00108       
00109       if ( buffer.remaining() < bytes_needed )
00110         buffer.read_more(bytes_needed);
00111       
00112       assert( buffer.remaining() >= bytes_needed );
00113       
00114       const unsigned char* p =
00115         reinterpret_cast<const unsigned char*>(buffer.get_buffer());
00116       
00117       std::transform( p, p + n, &m_image[m_y][m_x], m_palette );
00118       
00119       m_x += n;
00120 
00121       buffer.move(bytes_needed);
00122     } // bitmap::reader::rle_bitmap_output_buffer<false>::copy()

template<bool Coded4bits>
void claw::graphic::bitmap::reader::rle_bitmap_output_buffer< Coded4bits >::copy ( unsigned int  n,
file_input_buffer buffer 
)
template<bool Coded4Bits>
void claw::graphic::bitmap::reader::rle_bitmap_output_buffer< Coded4Bits >::delta_move ( unsigned char  x,
unsigned char  y 
) [inline]

Move the cursor horizontally and vertically.

Parameters:
x Horizontal displacement.
y Vertical displacement.

Definition at line 72 of file bitmap_reader.tpp.

00073 {
00074   assert( m_x + x < m_image.width() );
00075   assert( m_y + y < m_image.height() );
00076 
00077   m_x += x;
00078   m_y += y;
00079 } // bitmap::reader::rle_bitmap_output_buffer::delta_move()

template<>
void claw::graphic::bitmap::reader::rle_bitmap_output_buffer< true >::fill ( unsigned int  n,
unsigned char  pattern 
) [inline]
Parameters:
n Number of pixels to fill.
pattern The index of the two colors to copy.
Remarks:
This method is for 4bpp bitmaps.

Definition at line 70 of file bitmap_reader.cpp.

00071     {
00072       assert( m_x + n <= m_image.width() );
00073       
00074       for (unsigned int i = 0; i != n / 2; ++i, m_x += 2)
00075         {
00076           m_image[m_y][m_x] = m_palette[ (pattern & 0xF0) >> 4 ];
00077           m_image[m_y][m_x+1] = m_palette[ pattern & 0x0F ];
00078         }
00079       
00080       if ( n % 2 )
00081         {
00082           m_image[m_y][m_x] = m_palette[ (pattern & 0xF0) >> 4 ];
00083           ++m_x;
00084         }
00085     } // bitmap::reader::rle_bitmap_output_buffer<false>::fill()

template<>
void claw::graphic::bitmap::reader::rle_bitmap_output_buffer< false >::fill ( unsigned int  n,
unsigned char  pattern 
) [inline]
Parameters:
n Number of copies.
pattern The index of the color to copy.
Remarks:
This method is for 8bpp bitmaps.

Definition at line 46 of file bitmap_reader.cpp.

00047     {
00048       assert( m_x + n <= m_image.width() );
00049       
00050       std::fill(&m_image[m_y][m_x], &m_image[m_y][m_x] + n, m_palette[pattern]);
00051       
00052       m_x += n;
00053     } // bitmap::reader::rle_bitmap_output_buffer<false>::fill()

template<bool Coded4bits>
void claw::graphic::bitmap::reader::rle_bitmap_output_buffer< Coded4bits >::fill ( unsigned int  n,
unsigned char  pattern 
)
template<bool Coded4Bits>
void claw::graphic::bitmap::reader::rle_bitmap_output_buffer< Coded4Bits >::next_line (  )  [inline]

Go to the begining of the next line to fill.

Definition at line 55 of file bitmap_reader.tpp.

00056 {
00057   assert( m_y > 0 );
00058 
00059   m_x = 0;
00060   --m_y;
00061 } // bitmap::reader::rle_bitmap_output_buffer::next_line()


Member Data Documentation

template<bool Coded4bits>
image& claw::graphic::bitmap::reader::rle_bitmap_output_buffer< Coded4bits >::m_image [private]

The image to fill.

Definition at line 169 of file bitmap.hpp.

template<bool Coded4bits>
const color_palette_type& claw::graphic::bitmap::reader::rle_bitmap_output_buffer< Coded4bits >::m_palette [private]

Color palette.

Definition at line 166 of file bitmap.hpp.

template<bool Coded4bits>
unsigned int claw::graphic::bitmap::reader::rle_bitmap_output_buffer< Coded4bits >::m_x [private]

Current column index in the bitmap.

Definition at line 172 of file bitmap.hpp.

template<bool Coded4bits>
unsigned int claw::graphic::bitmap::reader::rle_bitmap_output_buffer< Coded4bits >::m_y [private]

Current row index in the bitmap.

Definition at line 175 of file bitmap.hpp.


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