Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/pnmimage/pnmImageHeader.I

Go to the documentation of this file.
00001 // Filename: pnmImageHeader.I
00002 // Created by:  drose (15Jun00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 ////////////////////////////////////////////////////////////////////
00020 //     Function: PNMImageHeader::Constructor
00021 //       Access: Public
00022 //  Description:
00023 ////////////////////////////////////////////////////////////////////
00024 INLINE PNMImageHeader::
00025 PNMImageHeader() {
00026   _x_size = 0;
00027   _y_size = 0;
00028   _num_channels = 0;
00029   _maxval = 255;
00030   _type = (PNMFileType *)NULL;
00031 }
00032 
00033 ////////////////////////////////////////////////////////////////////
00034 //     Function: PNMImageHeader::Copy Constructor
00035 //       Access: Public
00036 //  Description:
00037 ////////////////////////////////////////////////////////////////////
00038 INLINE PNMImageHeader::
00039 PNMImageHeader(const PNMImageHeader &copy) :
00040   _x_size(copy._x_size),
00041   _y_size(copy._y_size),
00042   _num_channels(copy._num_channels),
00043   _maxval(copy._maxval),
00044   _type(copy._type)
00045 {
00046 }
00047 
00048 ////////////////////////////////////////////////////////////////////
00049 //     Function: PNMImageHeader::Copy Assignment Operator
00050 //       Access: Public
00051 //  Description:
00052 ////////////////////////////////////////////////////////////////////
00053 INLINE void PNMImageHeader::
00054 operator = (const PNMImageHeader &copy) {
00055   _x_size = copy._x_size;
00056   _y_size = copy._y_size;
00057   _num_channels = copy._num_channels;
00058   _maxval = copy._maxval;
00059   _type = copy._type;
00060 }
00061 
00062 ////////////////////////////////////////////////////////////////////
00063 //     Function: PNMImageHeader::Destructor
00064 //       Access: Public
00065 //  Description:
00066 ////////////////////////////////////////////////////////////////////
00067 INLINE PNMImageHeader::
00068 ~PNMImageHeader() {
00069 }
00070 
00071 ////////////////////////////////////////////////////////////////////
00072 //     Function: PNMImageHeader::get_color_type
00073 //       Access: Public
00074 //  Description: Returns the image type of the image, as an enumerated
00075 //               value.  This is really just the number of channels
00076 //               cast to the enumerated type.
00077 ////////////////////////////////////////////////////////////////////
00078 INLINE PNMImageHeader::ColorType PNMImageHeader::
00079 get_color_type() const {
00080   nassertr(_num_channels >= 1 && _num_channels <= 4, CT_invalid);
00081   return (ColorType)_num_channels;
00082 }
00083 
00084 ////////////////////////////////////////////////////////////////////
00085 //     Function: PNMImageHeader::get_num_channels
00086 //       Access: Public
00087 //  Description: Returns the number of channels in the image.
00088 ////////////////////////////////////////////////////////////////////
00089 INLINE int PNMImageHeader::
00090 get_num_channels() const {
00091   nassertr(_num_channels >= 1 && _num_channels <= 4, 0);
00092   return _num_channels;
00093 }
00094 
00095 ////////////////////////////////////////////////////////////////////
00096 //     Function: PNMImageHeader::is_grayscale
00097 //       Access: Public, Static
00098 //  Description: This static variant of is_grayscale() returns true if
00099 //               the indicated image type represents a grayscale
00100 //               image, false otherwise.
00101 ////////////////////////////////////////////////////////////////////
00102 INLINE bool PNMImageHeader::
00103 is_grayscale(PNMImageHeader::ColorType color_type) {
00104   return (color_type == CT_grayscale || color_type == CT_two_channel);
00105 }
00106 
00107 ////////////////////////////////////////////////////////////////////
00108 //     Function: PNMImageHeader::is_grayscale
00109 //       Access: Public
00110 //  Description: Returns false if the image is a full-color image, and
00111 //               has red, green, and blue components; true if it is a
00112 //               grayscale image and has only a gray component.  (The
00113 //               gray color is actually stored in the blue channel,
00114 //               and the red and green channels are ignored.)
00115 ////////////////////////////////////////////////////////////////////
00116 INLINE bool PNMImageHeader::
00117 is_grayscale() const {
00118   return is_grayscale(get_color_type());
00119 }
00120 
00121 ////////////////////////////////////////////////////////////////////
00122 //     Function: PNMImageHeader::has_alpha
00123 //       Access: Public, Static
00124 //  Description: This static variant of has_alpha() returns true if
00125 //               the indicated image type includes an alpha channel,
00126 //               false otherwise.
00127 ////////////////////////////////////////////////////////////////////
00128 INLINE bool PNMImageHeader::
00129 has_alpha(PNMImageHeader::ColorType color_type) {
00130   return (color_type == CT_two_channel || color_type == CT_four_channel);
00131 }
00132 
00133 ////////////////////////////////////////////////////////////////////
00134 //     Function: PNMImageHeader::has_alpha
00135 //       Access: Public
00136 //  Description: Returns true if the image includes an alpha channel,
00137 //               false otherwise.  Unlike is_grayscale(), if this
00138 //               returns false it is an error to call any of the
00139 //               functions accessing the alpha channel.
00140 ////////////////////////////////////////////////////////////////////
00141 INLINE bool PNMImageHeader::
00142 has_alpha() const {
00143   return has_alpha(get_color_type());
00144 }
00145 
00146 ////////////////////////////////////////////////////////////////////
00147 //     Function: PNMImageHeader::get_maxval
00148 //       Access: Public
00149 //  Description: Returns the maximum channel value allowable for any
00150 //               pixel in this image; for instance, 255 for a typical
00151 //               8-bit-per-channel image.  A pixel with this value is
00152 //               full on.
00153 ////////////////////////////////////////////////////////////////////
00154 INLINE xelval PNMImageHeader::
00155 get_maxval() const {
00156   return _maxval;
00157 }
00158 
00159 ////////////////////////////////////////////////////////////////////
00160 //     Function: PNMImageHeader::get_x_size
00161 //       Access: Public
00162 //  Description: Returns the number of pixels in the X direction.
00163 //               This is one more than the largest allowable X
00164 //               coordinate.
00165 ////////////////////////////////////////////////////////////////////
00166 INLINE int PNMImageHeader::
00167 get_x_size() const {
00168   return _x_size;
00169 }
00170 
00171 ////////////////////////////////////////////////////////////////////
00172 //     Function: PNMImageHeader::get_y_size
00173 //       Access: Public
00174 //  Description: Returns the number of pixels in the Y direction.
00175 //               This is one more than the largest allowable Y
00176 //               coordinate.
00177 ////////////////////////////////////////////////////////////////////
00178 INLINE int PNMImageHeader::
00179 get_y_size() const {
00180   return _y_size;
00181 }
00182 
00183 ////////////////////////////////////////////////////////////////////
00184 //     Function: PNMImageHeader::has_type
00185 //       Access: Public
00186 //  Description: Returns true if the PNMImageHeader knows what type it
00187 //               is, false otherwise.
00188 ////////////////////////////////////////////////////////////////////
00189 INLINE bool PNMImageHeader::
00190 has_type() const {
00191   return _type != (PNMFileType *)NULL;
00192 }
00193 
00194 ////////////////////////////////////////////////////////////////////
00195 //     Function: PNMImageHeader::get_type
00196 //       Access: Public
00197 //  Description: If the file type is known (e.g. has_type() returns
00198 //               true), returns its PNMFileType pointer; otherwise,
00199 //               returns NULL.
00200 ////////////////////////////////////////////////////////////////////
00201 INLINE PNMFileType *PNMImageHeader::
00202 get_type() const {
00203   return _type;
00204 }
00205 
00206 ////////////////////////////////////////////////////////////////////
00207 //     Function: PNMImageHeader::set_type
00208 //       Access: Public
00209 //  Description: Sets the file type of this PNMImage.  This will be
00210 //               the default type used when an image is read, if the
00211 //               type cannot be determined by magic number or inferred
00212 //               by extension, or the type used when the image is
00213 //               written, if the type cannot be inferred from the
00214 //               filename extension.
00215 ////////////////////////////////////////////////////////////////////
00216 INLINE void PNMImageHeader::
00217 set_type(PNMFileType *type) {
00218   _type = type;
00219 }

Generated on Fri May 2 00:43:09 2003 for Panda by doxygen1.3