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