Panda3D
|
00001 // Filename: pnmReader.h 00002 // Created by: drose (14Jun00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef PNMREADER_H 00016 #define PNMREADER_H 00017 00018 #include "pandabase.h" 00019 00020 #include "pnmImageHeader.h" 00021 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Class : PNMReader 00025 // Description : This is an abstract base class that defines the 00026 // interface for reading image files of various types. 00027 // Any particular image file type that can be read must 00028 // define a class that inherits from PNMReader to read 00029 // it. 00030 //////////////////////////////////////////////////////////////////// 00031 class EXPCL_PANDA_PNMIMAGE PNMReader : public PNMImageHeader { 00032 protected: 00033 INLINE PNMReader(PNMFileType *type, istream *file, bool owns_file); 00034 00035 public: 00036 virtual ~PNMReader(); 00037 INLINE void set_read_size(int x_size, int y_size); 00038 00039 INLINE PNMFileType *get_type() const; 00040 00041 virtual void prepare_read(); 00042 virtual int read_data(xel *array, xelval *alpha); 00043 virtual bool supports_read_row() const; 00044 virtual bool read_row(xel *array, xelval *alpha, int x_size, int y_size); 00045 00046 virtual bool supports_stream_read() const; 00047 00048 INLINE bool is_valid() const; 00049 00050 private: 00051 int get_reduction_shift(int orig_size, int new_size); 00052 00053 protected: 00054 PNMFileType *_type; 00055 bool _owns_file; 00056 istream *_file; 00057 bool _is_valid; 00058 00059 int _read_x_size, _read_y_size; 00060 bool _has_read_size; 00061 00062 int _x_shift, _y_shift; 00063 int _orig_x_size, _orig_y_size; 00064 }; 00065 00066 #include "pnmReader.I" 00067 00068 #endif