84 f <<
"#define " << opt.
name <<
"_width " << m_image.width() <<
"\n";
85 f <<
"#define " << opt.
name <<
"_height " << m_image.height() <<
"\n";
89 f <<
"#define " << opt.
name <<
"_x_hot " << opt.
hot->
x <<
"\n";
90 f <<
"#define " << opt.
name <<
"_y_hot " << opt.
hot->
y <<
"\n";
93 f <<
"static unsigned char " << opt.
name <<
"_bits[] = {\n ";
102void claw::graphic::xbm::writer::save_bits(std::ostream& f)
const
104 const unsigned int max_per_line = (80 - 1) / 6;
105 const unsigned int nb_pxl = m_image.width() * m_image.height();
107 unsigned int pxl_count = 0;
108 unsigned int per_line = 0;
110 for(
unsigned int y = 0; y != m_image.height(); ++y)
114 while(x != m_image.width())
119 for(bits = 0; (x != m_image.width()) && (bits != 8);
120 ++bits, ++x, ++pxl_count)
123 if(m_image[y][x].luminosity() <= 127)
131 f <<
" 0x" << std::setw(2) << std::setfill(
'0') << std::hex << v;
133 if(pxl_count != nb_pxl)
137 if(per_line == max_per_line)
146 f <<
"};" << std::endl;
#define CLAW_PRECOND(b)
Abort the program if a precondition is not true.
image()
Constructor. Creates an image without datas.
void save(std::ostream &f, const options &opt=options()) const
Save the image in a XBM file.
writer(const image &img)
Constructor.
Coordinates in a two dimensional space.
value_type x
X-coordinate.
value_type y
Y-coordinate.
Parameters of the writing algorithm.
options()
Default constructor.
const claw::math::coordinate_2d< int > * hot
The position of the hot spot in the image.
std::string name
The name of the image structure in the file.
A class for xbm pictures.