00001 // Filename: pnmWriter.I 00002 // Created by: drose (16Jun00) 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 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: PNMWriter::Constructor 00018 // Access: Protected 00019 // Description: 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE PNMWriter:: 00022 PNMWriter(PNMFileType *type, ostream *file, bool owns_file) : 00023 _type(type), 00024 _owns_file(owns_file), 00025 _file(file), 00026 _is_valid(true) 00027 { 00028 } 00029 00030 //////////////////////////////////////////////////////////////////// 00031 // Function: PNMWriter::get_type 00032 // Access: Public 00033 // Description: Returns a pointer to the PNMFileType object that 00034 // created this PNMWriter. 00035 //////////////////////////////////////////////////////////////////// 00036 INLINE PNMFileType *PNMWriter:: 00037 get_type() const { 00038 return _type; 00039 } 00040 00041 //////////////////////////////////////////////////////////////////// 00042 // Function: PNMWriter::set_color_type 00043 // Access: Public 00044 // Description: 00045 //////////////////////////////////////////////////////////////////// 00046 INLINE void PNMWriter:: 00047 set_color_type(ColorType type) { 00048 set_num_channels((int)type); 00049 } 00050 00051 //////////////////////////////////////////////////////////////////// 00052 // Function: PNMWriter::set_num_channels 00053 // Access: Public 00054 // Description: 00055 //////////////////////////////////////////////////////////////////// 00056 INLINE void PNMWriter:: 00057 set_num_channels(int num_channels) { 00058 nassertv(num_channels >= 1 && num_channels <= 4); 00059 _num_channels = num_channels; 00060 } 00061 00062 //////////////////////////////////////////////////////////////////// 00063 // Function: PNMWriter::set_maxval 00064 // Access: Public 00065 // Description: 00066 //////////////////////////////////////////////////////////////////// 00067 INLINE void PNMWriter:: 00068 set_maxval(xelval maxval) { 00069 _maxval = maxval; 00070 } 00071 00072 //////////////////////////////////////////////////////////////////// 00073 // Function: PNMWriter::set_x_size 00074 // Access: Public 00075 // Description: 00076 //////////////////////////////////////////////////////////////////// 00077 INLINE void PNMWriter:: 00078 set_x_size(int x_size) { 00079 nassertv(x_size >= 0); 00080 _x_size = x_size; 00081 } 00082 00083 //////////////////////////////////////////////////////////////////// 00084 // Function: PNMWriter::set_y_size 00085 // Access: Public 00086 // Description: 00087 //////////////////////////////////////////////////////////////////// 00088 INLINE void PNMWriter:: 00089 set_y_size(int y_size) { 00090 nassertv(y_size >= 0); 00091 _y_size = y_size; 00092 } 00093 00094 //////////////////////////////////////////////////////////////////// 00095 // Function: PNMWriter::copy_header_from 00096 // Access: Public 00097 // Description: Initializes all the data in the header (x_size, 00098 // y_size, num_channels, etc.) to the same values 00099 // indicated in the given header. This should be done 00100 // before writing anything to the file. 00101 //////////////////////////////////////////////////////////////////// 00102 INLINE void PNMWriter:: 00103 copy_header_from(const PNMImageHeader &header) { 00104 PNMImageHeader::operator = (header); 00105 } 00106 00107 //////////////////////////////////////////////////////////////////// 00108 // Function: PNMWriter::is_valid 00109 // Access: Public 00110 // Description: Returns true if the PNMWriter can be used to write 00111 // data, false if something is wrong. 00112 //////////////////////////////////////////////////////////////////// 00113 INLINE bool PNMWriter:: 00114 is_valid() const { 00115 return _is_valid; 00116 }