40 template<
bool Coded4Bits >
41 claw::graphic::bitmap::reader::
42 rle_bitmap_output_buffer<Coded4Bits>::rle_bitmap_output_buffer
43 (
const color_palette_type& palette, image& img )
44 : m_palette(palette), m_image(img), m_x(0), m_y(m_image.height() - 1)
53 template<
bool Coded4Bits >
54 void claw::graphic::bitmap::reader::
55 rle_bitmap_output_buffer<Coded4Bits>::next_line()
69 template<
bool Coded4Bits >
70 void claw::graphic::bitmap::reader::
71 rle_bitmap_output_buffer<Coded4Bits>::delta_move
72 (
unsigned char x,
unsigned char y)
74 assert( m_x + x < m_image.width() );
75 assert( m_y + y < m_image.height() );
92 template<
typename OutputBuffer >
93 void claw::graphic::bitmap::reader::rle_bitmap_decoder<OutputBuffer>::read_mode
94 ( file_input_buffer& input, output_buffer_type& output)
96 this->m_mode = this->stop;
99 if ( input.remaining() < 2)
100 ok = input.read_more(2);
104 unsigned char key, pattern;
106 key = input.get_next();
107 pattern = input.get_next();
112 this->m_mode = this->compressed;
114 this->m_pattern = pattern;
116 else switch( pattern )
119 case 0 : output.next_line(); read_mode(input, output);
break;
121 case 1 : this->m_mode = this->stop;
break;
125 if ( input.remaining() < 1 )
126 ok = input.read_more(1);
132 y = input.get_next();
133 output.delta_move(x, y);
134 read_mode(input, output);
139 default: this->m_mode = this->raw; this->m_count = pattern;
break;
159 template<
typename Convert>
160 void claw::graphic::bitmap::reader::load_rgb_data
161 ( std::istream& f,
unsigned int buffer_size,
const color_palette_type& palette,
162 const Convert& pixel_convert )
167 if (buffer_size % 4 != 0)
168 buffer_size += 4 - buffer_size % 4;
170 char* buffer =
new char[buffer_size];
172 for (line = m_image.height(); (line>0) && !f.eof(); )
175 f.read(buffer, buffer_size);
176 pixel_convert( m_image[line], buffer, palette );
181 if ( f.rdstate() != std::ios_base::goodbit )