PNMImage::reverse_rows()

This commit is contained in:
David Rose 2012-01-19 18:22:22 +00:00
parent 38de5011e1
commit 6f88d641bf
2 changed files with 30 additions and 0 deletions

View File

@ -484,6 +484,34 @@ make_grayscale(double rc, double gc, double bc) {
setup_rc();
}
////////////////////////////////////////////////////////////////////
// Function: PNMImage::reverse_rows
// Access: Published
// Description: Performs an in-place reversal of the row (y) data.
////////////////////////////////////////////////////////////////////
void PNMImage::
reverse_rows() {
if (_array != NULL) {
xel *new_array = (xel *)PANDA_MALLOC_ARRAY(_x_size * _y_size * sizeof(xel));
for (int y = 0; y < _y_size; y++) {
int new_y = _y_size - 1 - y;
memcpy(new_array + new_y * _x_size, _array + y * _x_size, _x_size * sizeof(xel));
}
PANDA_FREE_ARRAY(_array);
_array = new_array;
}
if (_alpha != NULL) {
xelval *new_alpha = (xelval *)PANDA_MALLOC_ARRAY(_x_size * _y_size * sizeof(xelval));
for (int y = 0; y < _y_size; y++) {
int new_y = _y_size - 1 - y;
memcpy(new_alpha + new_y * _x_size, _alpha + y * _x_size, _x_size * sizeof(xelval));
}
PANDA_FREE_ARRAY(_alpha);
_alpha = new_alpha;
}
}
////////////////////////////////////////////////////////////////////
// Function: PNMImage::set_maxval
// Access: Published

View File

@ -116,6 +116,8 @@ PUBLISHED:
void make_grayscale(double rc, double gc, double bc);
INLINE void make_rgb();
BLOCKING void reverse_rows();
BLOCKING void set_maxval(xelval maxval);
// The *_val() functions return or set the color values in the range