The output buffer for the RLE decoder. More...
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_type & | m_palette |
Color palette. | |
image & | m_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. |
The output buffer for the RLE decoder.
Template parameters
Definition at line 152 of file bitmap.hpp.
claw::graphic::bitmap::reader::rle_bitmap_output_buffer< Coded4Bits >::rle_bitmap_output_buffer | ( | const color_palette_type & | palette, | |
image & | img | |||
) | [inline] |
Constructor.
palette | The color palette to convert the pixels. | |
img | The image we're filling. |
Definition at line 43 of file bitmap_reader.tpp.
void claw::graphic::bitmap::reader::rle_bitmap_output_buffer< true >::copy | ( | unsigned int | n, | |
file_input_buffer & | buffer | |||
) | [inline] |
n | The number of pixels to copy. | |
buffer | The input buffer, to copy from. |
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()
void claw::graphic::bitmap::reader::rle_bitmap_output_buffer< false >::copy | ( | unsigned int | n, | |
file_input_buffer & | buffer | |||
) | [inline] |
n | The number of pixels to copy. | |
buffer | The input buffer, to copy from. |
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()
void claw::graphic::bitmap::reader::rle_bitmap_output_buffer< Coded4bits >::copy | ( | unsigned int | n, | |
file_input_buffer & | buffer | |||
) |
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.
x | Horizontal displacement. | |
y | Vertical displacement. |
Definition at line 72 of file bitmap_reader.tpp.
void claw::graphic::bitmap::reader::rle_bitmap_output_buffer< true >::fill | ( | unsigned int | n, | |
unsigned char | pattern | |||
) | [inline] |
n | Number of pixels to fill. | |
pattern | The index of the two colors to copy. |
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()
void claw::graphic::bitmap::reader::rle_bitmap_output_buffer< false >::fill | ( | unsigned int | n, | |
unsigned char | pattern | |||
) | [inline] |
n | Number of copies. | |
pattern | The index of the color to copy. |
Definition at line 46 of file bitmap_reader.cpp.
void claw::graphic::bitmap::reader::rle_bitmap_output_buffer< Coded4bits >::fill | ( | unsigned int | n, | |
unsigned char | pattern | |||
) |
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.
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.
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.
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.
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.