fix roundoff error in fill()

This commit is contained in:
David Rose 2009-11-18 22:55:52 +00:00
parent ddd8d012e8
commit 5b92b341b6
3 changed files with 19 additions and 4 deletions

View File

@ -116,9 +116,7 @@ from_val(xelval input_value) const {
////////////////////////////////////////////////////////////////////
INLINE void PNMImage::
fill(double red, double green, double blue) {
fill_val((xelval)(red * get_maxval()),
(xelval)(green * get_maxval()),
(xelval)(blue * get_maxval()));
fill_val(to_val(red), to_val(green), to_val(blue));
}
////////////////////////////////////////////////////////////////////
@ -150,7 +148,7 @@ fill_val(xelval gray) {
////////////////////////////////////////////////////////////////////
INLINE void PNMImage::
alpha_fill(double alpha) {
alpha_fill_val((xelval)(alpha * get_maxval()));
alpha_fill_val(to_val(alpha));
}
////////////////////////////////////////////////////////////////////

View File

@ -542,3 +542,18 @@ output(ostream &out) const {
out << "(" << _red << ", " << _green << ", " << _blue << ", " << _alpha << ")";
}
////////////////////////////////////////////////////////////////////
// Function: PNMImageHeader::Histogram::write
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
void PNMImageHeader::Histogram::
write(ostream &out) const {
out << "Histogram: {\n";
PixelCount::const_iterator pi;
for (pi = _pixels.begin(); pi != _pixels.end(); ++pi) {
out << " " << (*pi)._pixel << ": " << (*pi)._count << ",\n";
}
out << "}\n";
}

View File

@ -167,6 +167,8 @@ PUBLISHED:
INLINE int get_count(const PixelSpec &pixel) const;
MAKE_SEQ(get_pixels, get_num_pixels, get_pixel);
void write(ostream &out) const;
public:
INLINE void swap(PixelCount &pixels, HistMap &hist_map);