more low-level pnmimage accessors

This commit is contained in:
David Rose 2012-07-23 02:09:46 +00:00
parent 05aa20ee3f
commit bd6100bcab
3 changed files with 129 additions and 0 deletions

View File

@ -900,6 +900,82 @@ apply_exponent(double red_exponent, double green_exponent, double blue_exponent)
}
////////////////////////////////////////////////////////////////////
// Function: PNMImage::get_array
// Access: Public
// Description: Directly access the underlying PNMImage array. Know
// what you are doing!
////////////////////////////////////////////////////////////////////
INLINE xel *PNMImage::
get_array() {
return _array;
}
////////////////////////////////////////////////////////////////////
// Function: PNMImage::get_array
// Access: Public
// Description: Directly access the underlying PNMImage array. Know
// what you are doing!
////////////////////////////////////////////////////////////////////
INLINE const xel *PNMImage::
get_array() const {
return _array;
}
////////////////////////////////////////////////////////////////////
// Function: PNMImage::get_alpha_array
// Access: Public
// Description: Directly access the underlying PNMImage array of
// alpha values. Know what you are doing!
////////////////////////////////////////////////////////////////////
INLINE xelval *PNMImage::
get_alpha_array() {
return _alpha;
}
////////////////////////////////////////////////////////////////////
// Function: PNMImage::get_alpha_array
// Access: Public
// Description: Directly access the underlying PNMImage array of
// alpha values. Know what you are doing!
////////////////////////////////////////////////////////////////////
INLINE const xelval *PNMImage::
get_alpha_array() const {
return _alpha;
}
////////////////////////////////////////////////////////////////////
// Function: PNMImage::take_array
// Access: Public
// Description: Returns the underlying PNMImage array and removes it
// from the PNMImage. You become the owner of this
// array and must eventually free it with
// PANDA_FREE_ARRAY() (or pass it to another PNMImage
// with set_array()). Know what you are doing!
////////////////////////////////////////////////////////////////////
INLINE xel *PNMImage::
take_array() {
xel *array = _array;
_array = NULL;
return array;
}
////////////////////////////////////////////////////////////////////
// Function: PNMImage::take_alpha_array
// Access: Public
// Description: Returns the underlying PNMImage array and removes it
// from the PNMImage. You become the owner of this
// array and must eventually free it with
// PANDA_FREE_ARRAY() (or pass it to another PNMImage
// with set_alpha_array()). Know what you are doing!
////////////////////////////////////////////////////////////////////
INLINE xelval *PNMImage::
take_alpha_array() {
xelval *alpha = _alpha;
_alpha = NULL;
return alpha;
}
////////////////////////////////////////////////////////////////////
// Function: PNMImage::allocate_array
// Access: Private

View File

@ -716,6 +716,46 @@ blend(int x, int y, double r, double g, double b, double alpha) {
}
}
////////////////////////////////////////////////////////////////////
// Function: PNMImage::set_array
// Access: Public
// Description: Replaces the underlying PNMImage array with the
// indicated pointer. Know what you are doing! The new
// array must be the correct size and must have been
// allocated via PANDA_MALLOC_ARRAY(). The PNMImage
// object becomes the owner of this pointer and will
// eventually free it with PANDA_FREE_ARRAY(). The
// previous array, if any, will be freed with
// PANDA_FREE_ARRAY() when this call is made.
////////////////////////////////////////////////////////////////////
void PNMImage::
set_array(xel *array) {
if (_array != (xel *)NULL) {
PANDA_FREE_ARRAY(_array);
}
_array = array;
}
////////////////////////////////////////////////////////////////////
// Function: PNMImage::set_alpha_array
// Access: Public
// Description: Replaces the underlying PNMImage alpha array with the
// indicated pointer. Know what you are doing! The new
// array must be the correct size and must have been
// allocated via PANDA_MALLOC_ARRAY(). The PNMImage
// object becomes the owner of this pointer and will
// eventually free it with PANDA_FREE_ARRAY(). The
// previous array, if any, will be freed with
// PANDA_FREE_ARRAY() when this call is made.
////////////////////////////////////////////////////////////////////
void PNMImage::
set_alpha_array(xelval *alpha) {
if (_alpha != (xelval *)NULL) {
PANDA_FREE_ARRAY(_alpha);
}
_alpha = alpha;
}
////////////////////////////////////////////////////////////////////
// Function: PNMImage::copy_sub_image
// Access: Published

View File

@ -252,6 +252,19 @@ PUBLISHED:
LColord get_average_xel_a() const;
double get_average_gray() const;
public:
// Know what you are doing if you access the underlying data arrays
// directly.
INLINE xel *get_array();
INLINE const xel *get_array() const;
INLINE xelval *get_alpha_array();
INLINE const xelval *get_alpha_array() const;
INLINE xel *take_array();
INLINE xelval *take_alpha_array();
void set_array(xel *array);
void set_alpha_array(xelval *alpha);
private:
INLINE void allocate_array();
INLINE void allocate_alpha();