00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef PNMIMAGEHEADER_H
00020 #define PNMIMAGEHEADER_H
00021
00022 #include "pandabase.h"
00023
00024 #include "pnmimage_base.h"
00025
00026 #include "typedObject.h"
00027 #include "filename.h"
00028
00029 class PNMFileType;
00030 class PNMReader;
00031 class PNMWriter;
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 class EXPCL_PANDA PNMImageHeader {
00044 public:
00045 INLINE PNMImageHeader();
00046 INLINE PNMImageHeader(const PNMImageHeader ©);
00047 INLINE void operator = (const PNMImageHeader ©);
00048 INLINE ~PNMImageHeader();
00049
00050
00051
00052
00053 enum ColorType {
00054 CT_invalid = 0,
00055 CT_grayscale = 1,
00056 CT_two_channel = 2,
00057 CT_color = 3,
00058 CT_four_channel = 4,
00059 };
00060
00061 INLINE ColorType get_color_type() const;
00062 INLINE int get_num_channels() const;
00063
00064 INLINE static bool is_grayscale(ColorType color_type);
00065 INLINE bool is_grayscale() const;
00066
00067 INLINE static bool has_alpha(ColorType color_type);
00068 INLINE bool has_alpha() const;
00069
00070 INLINE xelval get_maxval() const;
00071
00072 INLINE int get_x_size() const;
00073 INLINE int get_y_size() const;
00074
00075 INLINE bool has_type() const;
00076 INLINE PNMFileType *get_type() const;
00077 INLINE void set_type(PNMFileType *type);
00078
00079 bool read_header(const Filename &filename, PNMFileType *type = NULL);
00080
00081 PNMReader *make_reader(const Filename &filename,
00082 PNMFileType *type = NULL) const;
00083 PNMReader *make_reader(istream *file, bool owns_file = true,
00084 const Filename &filename = Filename(),
00085 string magic_number = string(),
00086 PNMFileType *type = NULL) const;
00087
00088 PNMWriter *make_writer(const Filename &filename,
00089 PNMFileType *type = NULL) const;
00090 PNMWriter *make_writer(ostream *file, bool owns_file = true,
00091 const Filename &filename = Filename(),
00092 PNMFileType *type = NULL) const;
00093
00094 static bool read_magic_number(istream *file, string &magic_number,
00095 int num_bytes);
00096
00097 void output(ostream &out) const;
00098
00099 protected:
00100 int _x_size, _y_size;
00101 int _num_channels;
00102 xelval _maxval;
00103 PNMFileType *_type;
00104 };
00105
00106 INLINE ostream &operator << (ostream &out, const PNMImageHeader &header) {
00107 header.output(out);
00108 return out;
00109 }
00110
00111 #include "pnmImageHeader.I"
00112
00113 #endif