mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
Add unary complement operator to PNMImage (ability to do ~image)
This commit is contained in:
parent
1a7653d146
commit
76f2f2b0ba
@ -1317,6 +1317,38 @@ setup_rc() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMImage::operator ~
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns a new PNMImage that is the
|
||||||
|
// complement of the current PNMImage.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
PNMImage PNMImage::
|
||||||
|
operator ~ () const {
|
||||||
|
PNMImage target (*this);
|
||||||
|
size_t array_size = _x_size * _y_size;
|
||||||
|
|
||||||
|
if (_array != NULL && _alpha != NULL) {
|
||||||
|
for (size_t i = 0; i < array_size; ++i) {
|
||||||
|
target._array[i].r = _maxval - _array[i].r;
|
||||||
|
target._array[i].g = _maxval - _array[i].g;
|
||||||
|
target._array[i].b = _maxval - _array[i].b;
|
||||||
|
target._alpha[i] = _maxval - _alpha[i];
|
||||||
|
}
|
||||||
|
} else if (_array != NULL) {
|
||||||
|
for (size_t i = 0; i < array_size; ++i) {
|
||||||
|
target._array[i].r = _maxval - _array[i].r;
|
||||||
|
target._array[i].g = _maxval - _array[i].g;
|
||||||
|
target._array[i].b = _maxval - _array[i].b;
|
||||||
|
}
|
||||||
|
} else if (_alpha != NULL) {
|
||||||
|
for (size_t i = 0; i < array_size; ++i) {
|
||||||
|
target._alpha[i] = _maxval - _alpha[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: PNMImage::operator +=
|
// Function: PNMImage::operator +=
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -254,6 +254,8 @@ private:
|
|||||||
void setup_rc();
|
void setup_rc();
|
||||||
|
|
||||||
PUBLISHED:
|
PUBLISHED:
|
||||||
|
PNMImage operator ~() const;
|
||||||
|
|
||||||
INLINE PNMImage operator + (const PNMImage &other) const;
|
INLINE PNMImage operator + (const PNMImage &other) const;
|
||||||
INLINE PNMImage operator + (const Colord &other) const;
|
INLINE PNMImage operator + (const Colord &other) const;
|
||||||
INLINE PNMImage operator - (const PNMImage &other) const;
|
INLINE PNMImage operator - (const PNMImage &other) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user