17 INLINE PNMImageHeader::
23 _color_space = CS_unspecified;
30 INLINE PNMImageHeader::
32 _x_size(copy._x_size),
33 _y_size(copy._y_size),
34 _num_channels(copy._num_channels),
35 _maxval(copy._maxval),
36 _color_space(copy._color_space),
44 INLINE
void PNMImageHeader::
46 _x_size = copy._x_size;
47 _y_size = copy._y_size;
48 _num_channels = copy._num_channels;
49 _maxval = copy._maxval;
50 _color_space = copy._color_space;
51 _comment = copy._comment;
58 INLINE PNMImageHeader::
68 nassertr(_num_channels >= 1 && _num_channels <= 4, CT_invalid);
69 return (ColorType)_num_channels;
75 INLINE
int PNMImageHeader::
76 get_num_channels()
const {
77 nassertr(_num_channels >= 1 && _num_channels <= 4, 0);
87 return (color_type == CT_grayscale || color_type == CT_two_channel);
107 return (color_type == CT_two_channel || color_type == CT_four_channel);
125 INLINE xelval PNMImageHeader::
134 INLINE ColorSpace PNMImageHeader::
135 get_color_space()
const {
161 INLINE LVecBase2i PNMImageHeader::
163 return LVecBase2i(_x_size, _y_size);
169 INLINE std::string PNMImageHeader::
170 get_comment()
const {
185 INLINE
bool PNMImageHeader::
187 return _type !=
nullptr;
213 INLINE
void PNMImageHeader::
218 HistMap::iterator hi = hist.insert(HistMap::value_type(color, 0)).first;
229 INLINE PNMImageHeader::PixelSpec::
230 PixelSpec(xelval gray_value) :
241 INLINE PNMImageHeader::PixelSpec::
242 PixelSpec(xelval gray_value, xelval alpha) :
253 INLINE PNMImageHeader::PixelSpec::
254 PixelSpec(xelval red, xelval green, xelval blue) :
265 INLINE PNMImageHeader::PixelSpec::
266 PixelSpec(xelval red, xelval green, xelval blue, xelval alpha) :
277 INLINE PNMImageHeader::PixelSpec::
278 PixelSpec(
const xel &rgb) :
280 _green(PPM_GETG(rgb)),
281 _blue(PPM_GETB(rgb)),
289 INLINE PNMImageHeader::PixelSpec::
290 PixelSpec(
const xel &rgb, xelval alpha) :
292 _green(PPM_GETG(rgb)),
293 _blue(PPM_GETB(rgb)),
301 INLINE
bool PNMImageHeader::PixelSpec::
302 operator < (
const PixelSpec &other)
const {
309 INLINE
bool PNMImageHeader::PixelSpec::
310 operator == (
const PixelSpec &other)
const {
317 INLINE
bool PNMImageHeader::PixelSpec::
318 operator != (
const PixelSpec &other)
const {
325 INLINE
int PNMImageHeader::PixelSpec::
326 compare_to(
const PixelSpec &other)
const {
327 if (_red != other._red) {
328 return _red < other._red ? -1 : 1;
330 if (_green != other._green) {
331 return _green < other._green ? -1 : 1;
333 if (_blue != other._blue) {
334 return _blue < other._blue ? -1 : 1;
336 if (_alpha != other._alpha) {
337 return _alpha < other._alpha ? -1 : 1;
345 INLINE xelval PNMImageHeader::PixelSpec::
353 INLINE xelval PNMImageHeader::PixelSpec::
361 INLINE xelval PNMImageHeader::PixelSpec::
369 INLINE xelval PNMImageHeader::PixelSpec::
377 INLINE
void PNMImageHeader::PixelSpec::
378 set_red(xelval red) {
385 INLINE
void PNMImageHeader::PixelSpec::
386 set_green(xelval green) {
393 INLINE
void PNMImageHeader::PixelSpec::
394 set_blue(xelval blue) {
401 INLINE
void PNMImageHeader::PixelSpec::
402 set_alpha(xelval alpha) {
412 nassertr(n >= 0 && n < size(), 0);
431 INLINE PNMImageHeader::PixelSpecCount::
444 return _count > other._count;
450 INLINE PNMImageHeader::Histogram::
457 INLINE
int PNMImageHeader::Histogram::
458 get_num_pixels()
const {
459 return _pixels.size();
468 nassertr(n >= 0 && n < (
int)_pixels.size(), _pixels[0]._pixel);
469 return _pixels[n]._pixel;
478 nassertr(n >= 0 && n < (
int)_pixels.size(), 0);
479 return _pixels[n]._count;
488 HistMap::const_iterator hi;
489 hi = _hist_map.find(
pixel);
490 if (hi == _hist_map.end()) {
502 _pixels.swap(pixels);
503 _hist_map.swap(hist_map);
This is the base class of a family of classes that represent particular image file types that PNMImag...
An STL function object class, this is intended to be used on any ordered collection of class objects ...