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 | |||
| ) |
| 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< true >::copy | ( | unsigned int | n, | |
| file_input_buffer & | buffer | |||
| ) |
| 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().
{
assert( m_x + n <= m_image.width() );
// RLE bitmap data is 2-bytes aligned
unsigned int bytes_needed = n / 2 + n % 2;
if ( bytes_needed % 2 )
++bytes_needed;
if ( buffer.remaining() < bytes_needed )
buffer.read_more( bytes_needed );
assert( buffer.remaining() >= bytes_needed );
const unsigned char* p =
reinterpret_cast<const unsigned char*>(buffer.get_buffer());
const unsigned char* last = p + n / 2;
for ( ; p != last; ++p, m_x += 2)
{
m_image[m_y][m_x] = m_palette[ (*p & 0xF0) >> 4 ];
m_image[m_y][m_x+1] = m_palette[ *p & 0x0F ];
}
if ( n % 2 )
{
m_image[m_y][m_x] = m_palette[ (*p & 0xF0) >> 4 ];
++m_x;
}
buffer.move( bytes_needed );
} // 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 | |||
| ) |
| 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().
{
assert( m_x + n <= m_image.width() );
// RLE bitmap data is 2-bytes aligned
const unsigned int bytes_needed = n + n % 2;
if ( buffer.remaining() < bytes_needed )
buffer.read_more(bytes_needed);
assert( buffer.remaining() >= bytes_needed );
const unsigned char* p =
reinterpret_cast<const unsigned char*>(buffer.get_buffer());
std::transform( p, p + n, &m_image[m_y][m_x], m_palette );
m_x += n;
buffer.move(bytes_needed);
} // bitmap::reader::rle_bitmap_output_buffer<false>::copy()
| void claw::graphic::bitmap::reader::rle_bitmap_output_buffer< Coded4Bits >::delta_move | ( | unsigned char | x, | |
| unsigned char | y | |||
| ) |
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< false >::fill | ( | unsigned int | n, | |
| unsigned char | pattern | |||
| ) |
| 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< true >::fill | ( | unsigned int | n, | |
| unsigned char | pattern | |||
| ) |
| n | Number of pixels to fill. | |
| pattern | The index of the two colors to copy. |
Definition at line 70 of file bitmap_reader.cpp.
{
assert( m_x + n <= m_image.width() );
for (unsigned int i = 0; i != n / 2; ++i, m_x += 2)
{
m_image[m_y][m_x] = m_palette[ (pattern & 0xF0) >> 4 ];
m_image[m_y][m_x+1] = m_palette[ pattern & 0x0F ];
}
if ( n % 2 )
{
m_image[m_y][m_x] = m_palette[ (pattern & 0xF0) >> 4 ];
++m_x;
}
} // bitmap::reader::rle_bitmap_output_buffer<false>::fill()
| void claw::graphic::bitmap::reader::rle_bitmap_output_buffer< Coded4Bits >::next_line | ( | ) |
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.
1.7.1