PfmFile::store_mask()

This commit is contained in:
David Rose 2012-11-07 19:08:32 +00:00
parent fd42201e74
commit 267e02c3d3
2 changed files with 25 additions and 0 deletions

View File

@ -446,6 +446,30 @@ store(PNMImage &pnmimage) const {
return true;
}
////////////////////////////////////////////////////////////////////
// Function: PfmFile::store_mask
// Access: Published
// Description: Stores 1 or 0 values into the indicated PNMImage,
// according to has_point() for each pixel. Each valid
// point gets a 1 value; each nonexistent point gets a 0
// value.
////////////////////////////////////////////////////////////////////
bool PfmFile::
store_mask(PNMImage &pnmimage) const {
if (!is_valid()) {
pnmimage.clear();
return false;
}
pnmimage.clear(get_x_size(), get_y_size(), 1, 255);
for (int yi = 0; yi < get_y_size(); ++yi) {
for (int xi = 0; xi < get_x_size(); ++xi) {
pnmimage.set_gray(xi, yi, has_point(xi, yi));
}
}
return true;
}
////////////////////////////////////////////////////////////////////
// Function: PfmFile::calc_average_point
// Access: Published

View File

@ -49,6 +49,7 @@ PUBLISHED:
BLOCKING bool load(const PNMImage &pnmimage);
BLOCKING bool store(PNMImage &pnmimage) const;
BLOCKING bool store_mask(PNMImage &pnmimage) const;
INLINE bool is_valid() const;