copy_channel_masked()

This commit is contained in:
David Rose 2014-01-29 17:30:40 +00:00
parent 618781e7cc
commit edd731b232
2 changed files with 24 additions and 0 deletions

View File

@ -1467,6 +1467,29 @@ copy_channel(int to_channel, const PfmFile &other, int from_channel) {
}
}
////////////////////////////////////////////////////////////////////
// Function: PfmFile::copy_channel_masked
// Access: Published
// Description: Copies just the specified channel values from the
// indicated PfmFile, but only where the other file has
// a data point.
////////////////////////////////////////////////////////////////////
void PfmFile::
copy_channel_masked(int to_channel, const PfmFile &other, int from_channel) {
nassertv(is_valid() && other.is_valid());
nassertv(other._x_size == _x_size && other._y_size == _y_size);
nassertv(to_channel >= 0 && to_channel < get_num_channels() &&
from_channel >= 0 && from_channel < other.get_num_channels());
for (int yi = 0; yi < _y_size; ++yi) {
for (int xi = 0; xi < _x_size; ++xi) {
if (other.has_point(xi, yi)) {
set_channel(xi, yi, to_channel, other.get_channel(xi, yi, from_channel));
}
}
}
}
////////////////////////////////////////////////////////////////////
// Function: PfmFile::apply_crop
// Access: Published

View File

@ -121,6 +121,7 @@ PUBLISHED:
BLOCKING void reverse_distort(const PfmFile &dist, PN_float32 scale_factor = 1.0);
BLOCKING void merge(const PfmFile &other);
BLOCKING void copy_channel(int to_channel, const PfmFile &other, int from_channel);
BLOCKING void copy_channel_masked(int to_channel, const PfmFile &other, int from_channel);
BLOCKING void apply_crop(int x_begin, int x_end, int y_begin, int y_end);
BLOCKING void clear_to_texcoords(int x_size, int y_size);