1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| Image::Image(int width, int height, const char* cheminImg, bool bin)
: _width(width), _height(height), _cheminImg(cheminImg), _bin(bin) {
_fluxImg.open( cheminImg, bin ? std::ios::binary : std::ios::out );
}
void Image::write_header() {
_fluxImg << (_bin?"P6\r":"P3\r")
<< _width << " " << _height << '\r'
<< RGB::_colorLevel << '\r';
}
void Image::write_color(float value) {
auto color = _cs.getLinColor( value );
if ( _bin ) {
char buf[3];
buf[0] = color._Red;
buf[1] = color._Green;
buf[2] = color._Blue;
_fluxImg.write( buf, 3 );
}
else
_fluxImg << color << '\r';
} |
Partager