mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
PNMImage::reverse_rows()
This commit is contained in:
parent
38de5011e1
commit
6f88d641bf
@ -484,6 +484,34 @@ make_grayscale(double rc, double gc, double bc) {
|
|||||||
setup_rc();
|
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
|
// Function: PNMImage::set_maxval
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -116,6 +116,8 @@ PUBLISHED:
|
|||||||
void make_grayscale(double rc, double gc, double bc);
|
void make_grayscale(double rc, double gc, double bc);
|
||||||
INLINE void make_rgb();
|
INLINE void make_rgb();
|
||||||
|
|
||||||
|
BLOCKING void reverse_rows();
|
||||||
|
|
||||||
BLOCKING void set_maxval(xelval maxval);
|
BLOCKING void set_maxval(xelval maxval);
|
||||||
|
|
||||||
// The *_val() functions return or set the color values in the range
|
// The *_val() functions return or set the color values in the range
|
||||||
|
Loading…
x
Reference in New Issue
Block a user