67 f.write( reinterpret_cast<char*>(&h),
sizeof(
header) );
77 void claw::graphic::bitmap::writer::save_data( std::ostream& f )
const
80 unsigned int buffer_size = m_image.width() * 3;
83 if (buffer_size % 4 != 0)
84 buffer_size += 4 - buffer_size % 4;
86 char* buffer =
new char[buffer_size];
88 for (line = m_image.height(); line>0; )
91 pixel32_to_pixel24( buffer, m_image[line] );
92 f.write(buffer, buffer_size);
104 void claw::graphic::bitmap::writer::pixel32_to_pixel24
105 (
char* dest,
const scanline& src )
const
107 unsigned int i24 = 0;
113 dest[i24++] =
first->components.blue;
114 dest[i24++] =
first->components.green;
115 dest[i24++] =
first->components.red;
124 void claw::graphic::bitmap::writer::init_header( header& h )
const
126 unsigned int adjusted_line = m_image.width() * 3;
128 if (m_image.width() % 4 != 0)
129 adjusted_line += 4 - m_image.width() % 4;
134 h.file_size = adjusted_line * m_image.height() +
sizeof(h);
138 h.data_offset =
sizeof(h);
140 h.header_size = 0x28;
142 h.width = m_image.width();
143 h.height = m_image.height();
146 h.compression = BMP_COMPRESSION_RGB;
147 h.image_size = adjusted_line * m_image.height();
151 h.importants_colors = 0;