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;
super::const_iterator const_iterator
Const iterator in the line.
unsigned int height() const
Gets image's height.
void save(std::ostream &f) const
Save the bitmap in a file.
Fuction object to get the first element of a std::pair.
iterator end()
Get en iterator past the last pixel.
A class for bitmap pictures.
unsigned int width() const
Gets image's width.
iterator begin()
Get an iterator on the first pixel.
writer(const image &img)
Constructor.
A class to deal with images.