63 f.write(reinterpret_cast<char*>(&h),
sizeof(
header));
72 void claw::graphic::bitmap::writer::save_data(std::ostream& f)
const 75 unsigned int buffer_size = m_image.width() * 3;
78 if(buffer_size % 4 != 0)
79 buffer_size += 4 - buffer_size % 4;
81 char* buffer =
new char[buffer_size];
83 for(line = m_image.height(); line > 0;)
86 pixel32_to_pixel24(buffer, m_image[line]);
87 f.write(buffer, buffer_size);
98 void claw::graphic::bitmap::writer::pixel32_to_pixel24(
99 char* dest,
const scanline& src)
const 101 unsigned int i24 = 0;
107 dest[i24++] =
first->components.blue;
108 dest[i24++] =
first->components.green;
109 dest[i24++] =
first->components.red;
117 void claw::graphic::bitmap::writer::init_header(header& h)
const 119 unsigned int adjusted_line = m_image.width() * 3;
121 if(m_image.width() % 4 != 0)
122 adjusted_line += 4 - m_image.width() % 4;
127 h.file_size = adjusted_line * m_image.height() +
sizeof(h);
131 h.data_offset =
sizeof(h);
133 h.header_size = 0x28;
135 h.width = m_image.width();
136 h.height = m_image.height();
139 h.compression = BMP_COMPRESSION_RGB;
140 h.image_size = adjusted_line * m_image.height();
144 h.importants_colors = 0;
super::const_iterator const_iterator
Const iterator in the line.
void save(std::ostream &f) const
Save the bitmap in a file.
Fuction object to get the first element of a std::pair.
A class for bitmap pictures.
writer(const image &img)
Constructor.
A class to deal with images.