Panda3D
|
00001 // Filename: pnmWriter.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 PNMWRITER_H 00016 #define PNMWRITER_H 00017 00018 #include "pandabase.h" 00019 00020 #include "pnmImageHeader.h" 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Class : PNMWriter 00024 // Description : This is an abstract base class that defines the 00025 // interface for writing image files of various types. 00026 // Any particular image file type that can be written 00027 // must define a class that inherits from PNMWriter to 00028 // write it. 00029 //////////////////////////////////////////////////////////////////// 00030 class EXPCL_PANDA_PNMIMAGE PNMWriter : public PNMImageHeader { 00031 protected: 00032 INLINE PNMWriter(PNMFileType *type, ostream *file, bool owns_file); 00033 00034 public: 00035 00036 // It is important to delete the PNMWriter class after successfully 00037 // writing the data. Failing to do this may result in some data not 00038 // getting flushed! 00039 virtual ~PNMWriter(); 00040 00041 INLINE PNMFileType *get_type() const; 00042 00043 INLINE void set_color_type(ColorType type); 00044 INLINE void set_num_channels(int num_channels); 00045 INLINE void set_maxval(xelval maxval); 00046 INLINE void set_x_size(int x_size); 00047 INLINE void set_y_size(int y_size); 00048 00049 INLINE void copy_header_from(const PNMImageHeader &header); 00050 00051 virtual int write_data(xel *array, xelval *alpha); 00052 virtual bool supports_write_row() const; 00053 virtual bool supports_grayscale() const; 00054 virtual bool write_header(); 00055 virtual bool write_row(xel *array, xelval *alpha); 00056 00057 virtual bool supports_stream_write() const; 00058 00059 INLINE bool is_valid() const; 00060 00061 protected: 00062 PNMFileType *_type; 00063 bool _owns_file; 00064 ostream *_file; 00065 bool _is_valid; 00066 }; 00067 00068 #include "pnmWriter.I" 00069 00070 #endif