mirror of
https://github.com/panda3d/panda3d.git
synced 2026-04-27 01:35:55 -05:00
pnmimage: fix PixelSpec coercion, add PixelSpec unit test
This commit is contained in:
@@ -295,29 +295,6 @@ PixelSpec(const xel &rgb, xelval alpha) :
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE PNMImageHeader::PixelSpec::
|
||||
PixelSpec(const PixelSpec ©) :
|
||||
_red(copy._red),
|
||||
_green(copy._green),
|
||||
_blue(copy._blue),
|
||||
_alpha(copy._alpha)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE void PNMImageHeader::PixelSpec::
|
||||
operator = (const PixelSpec ©) {
|
||||
_red = copy._red;
|
||||
_green = copy._green;
|
||||
_blue = copy._blue;
|
||||
_alpha = copy._alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -113,6 +113,9 @@ PUBLISHED:
|
||||
// make_histogram(). Note that pixels are stored by integer value, not by
|
||||
// floating-point scaled value.
|
||||
class EXPCL_PANDA_PNMIMAGE PixelSpec {
|
||||
public:
|
||||
INLINE PixelSpec() = default;
|
||||
|
||||
PUBLISHED:
|
||||
INLINE PixelSpec(xelval gray_value);
|
||||
INLINE PixelSpec(xelval gray_value, xelval alpha);
|
||||
@@ -120,8 +123,6 @@ PUBLISHED:
|
||||
INLINE PixelSpec(xelval red, xelval green, xelval blue, xelval alpha);
|
||||
INLINE PixelSpec(const xel &rgb);
|
||||
INLINE PixelSpec(const xel &rgb, xelval alpha);
|
||||
INLINE PixelSpec(const PixelSpec ©);
|
||||
INLINE void operator = (const PixelSpec ©);
|
||||
|
||||
INLINE bool operator < (const PixelSpec &other) const;
|
||||
INLINE bool operator == (const PixelSpec &other) const;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
from panda3d.core import PNMImage, PNMImageHeader
|
||||
|
||||
|
||||
def test_pixelspec_ctor():
|
||||
assert tuple(PNMImage.PixelSpec(1)) == (1, 1, 1, 0)
|
||||
assert tuple(PNMImage.PixelSpec(1, 2)) == (1, 1, 1, 2)
|
||||
assert tuple(PNMImage.PixelSpec(1, 2, 3)) == (1, 2, 3, 0)
|
||||
assert tuple(PNMImage.PixelSpec(1, 2, 3, 4)) == (1, 2, 3, 4)
|
||||
|
||||
assert tuple(PNMImage.PixelSpec((1, 2, 3))) == (1, 2, 3, 0)
|
||||
assert tuple(PNMImage.PixelSpec((1, 2, 3), 4)) == (1, 2, 3, 4)
|
||||
|
||||
# Copy constructor
|
||||
spec = PNMImage.PixelSpec(1, 2, 3, 4)
|
||||
assert tuple(PNMImage.PixelSpec(spec)) == (1, 2, 3, 4)
|
||||
|
||||
|
||||
def test_pixelspec_coerce():
|
||||
img = PNMImage(1, 1, 4)
|
||||
img.set_pixel(0, 0, (1, 2, 3, 4))
|
||||
assert img.get_pixel(0, 0) == (1, 2, 3, 4)
|
||||
Reference in New Issue
Block a user