38 : name(
"noname"), hot(NULL)
95 f <<
"#define " << opt.
name <<
"_width " << m_image.width() <<
"\n";
96 f <<
"#define " << opt.
name <<
"_height " << m_image.height() <<
"\n";
98 if ( opt.
hot != NULL )
100 f <<
"#define " << opt.
name <<
"_x_hot " << opt.
hot->
x <<
"\n";
101 f <<
"#define " << opt.
name <<
"_y_hot " << opt.
hot->
y <<
"\n";
104 f <<
"static unsigned char " << opt.
name <<
"_bits[] = {\n ";
114 void claw::graphic::xbm::writer::save_bits( std::ostream& f )
const 116 const unsigned int max_per_line = (80 - 1) / 6;
117 const unsigned int nb_pxl = m_image.width() * m_image.height();
119 unsigned int pxl_count = 0;
120 unsigned int per_line = 0;
122 for (
unsigned int y=0; y!=m_image.height(); ++y)
126 while ( x!=m_image.width() )
131 for ( bits=0; (x!=m_image.width()) && (bits != 8);
132 ++bits, ++x, ++pxl_count )
135 if ( m_image[y][x].luminosity() <= 127 )
143 f <<
" 0x" << std::setw(2) << std::setfill(
'0') << std::hex << v;
145 if ( pxl_count != nb_pxl )
149 if ( per_line == max_per_line )
158 f <<
"};" << std::endl;
Parameters of the writing algorithm.
options()
Default constructor.
std::string name
The name of the image structure in the file.
value_type y
Y-coordinate.
void save(std::ostream &os) const
Save the image.
const claw::math::coordinate_2d< int > * hot
The position of the hot spot in the image.
A class to deal with images.
void save(std::ostream &f, const options &opt=options()) const
Save the image in a XBM file.
A class for xbm pictures.
#define CLAW_PRECOND(b)
Abort the program if a precondition is not true.
writer(const image &img)
Constructor.
value_type x
X-coordinate.