53 if ( (pattern > 63) || (n > 1) )
55 u_int_8 cnt = 0xC0 | (
u_int_8)n;
56 m_stream.write( reinterpret_cast<char*>(&cnt),
sizeof(u_int_8) );
59 m_stream.write( reinterpret_cast<char*>(&pattern),
sizeof(u_int_8));
115 const unsigned int bytes_per_line = m_image.width() + m_image.width() % 2;
117 write_header(os, bytes_per_line);
118 save_rle_true_color(os, bytes_per_line);
127 void claw::graphic::pcx::writer::write_header
128 ( std::ostream& os,
unsigned int bytes_per_line )
const
138 h.window.x_max = m_image.width() - 1;
139 h.window.y_max = m_image.height() - 1;
140 h.horizontal_dpi = 72;
145 h.bytes_per_line = bytes_per_line;
147 h.screen_size.horizontal = 0;
148 h.screen_size.vertical = 0;
151 os.write( reinterpret_cast<char*>(&h),
sizeof(header) );
160 void claw::graphic::pcx::writer::save_rle_true_color
161 ( std::ostream& os,
unsigned int bytes_per_line )
const
163 std::vector<u_int_8> data(bytes_per_line, 0);
165 rle_pcx_encoder encoder;
166 file_output_buffer output(os);
168 for (
unsigned int y=0; y!=m_image.height(); ++y)
171 for (
unsigned int x=0; x!=m_image.width(); ++x)
172 data[x] = m_image[y][x].components.red;
174 encoder.encode( data.begin(), data.end(), output );
177 for (
unsigned int x=0; x!=m_image.width(); ++x)
178 data[x] = m_image[y][x].components.green;
180 encoder.encode( data.begin(), data.end(), output );
183 for (
unsigned int x=0; x!=m_image.width(); ++x)
184 data[x] = m_image[y][x].components.blue;
186 encoder.encode( data.begin(), data.end(), output );