00001 // Filename: imageFile.h 00002 // Created by: drose (28Nov00) 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 #ifndef IMAGEFILE_H 00020 #define IMAGEFILE_H 00021 00022 #include "pandatoolbase.h" 00023 00024 #include "textureProperties.h" 00025 00026 #include "filename.h" 00027 #include "typedWritable.h" 00028 00029 class PNMImage; 00030 class EggTexture; 00031 class PaletteGroup; 00032 00033 //////////////////////////////////////////////////////////////////// 00034 // Class : ImageFile 00035 // Description : This is the base class of both TextureImage and 00036 // PaletteImage. It encapsulates all the information 00037 // specific to an image file that can be assigned as a 00038 // texture image to egg geometry. 00039 //////////////////////////////////////////////////////////////////// 00040 class ImageFile : public TypedWritable { 00041 public: 00042 ImageFile(); 00043 00044 void make_shadow_image(const string &basename); 00045 00046 bool is_size_known() const; 00047 int get_x_size() const; 00048 int get_y_size() const; 00049 bool has_num_channels() const; 00050 int get_num_channels() const; 00051 00052 const TextureProperties &get_properties() const; 00053 void clear_basic_properties(); 00054 void update_properties(const TextureProperties &properties); 00055 00056 void set_filename(PaletteGroup *group, const string &basename); 00057 void set_filename(const string &dirname, const string &basename); 00058 const Filename &get_filename() const; 00059 const Filename &get_alpha_filename() const; 00060 int get_alpha_file_channel() const; 00061 bool exists() const; 00062 00063 bool read(PNMImage &image) const; 00064 bool write(const PNMImage &image) const; 00065 void unlink(); 00066 00067 void update_egg_tex(EggTexture *egg_tex) const; 00068 00069 void output_filename(ostream &out) const; 00070 00071 protected: 00072 TextureProperties _properties; 00073 Filename _filename; 00074 Filename _alpha_filename; 00075 int _alpha_file_channel; 00076 00077 bool _size_known; 00078 int _x_size, _y_size; 00079 00080 // The TypedWritable interface follows. 00081 public: 00082 virtual void write_datagram(BamWriter *writer, Datagram &datagram); 00083 virtual int complete_pointers(TypedWritable **p_list, 00084 BamReader *manager); 00085 00086 protected: 00087 void fillin(DatagramIterator &scan, BamReader *manager); 00088 00089 public: 00090 static TypeHandle get_class_type() { 00091 return _type_handle; 00092 } 00093 static void init_type() { 00094 TypedWritable::init_type(); 00095 register_type(_type_handle, "ImageFile", 00096 TypedWritable::get_class_type()); 00097 } 00098 virtual TypeHandle get_type() const { 00099 return get_class_type(); 00100 } 00101 00102 private: 00103 static TypeHandle _type_handle; 00104 00105 }; 00106 00107 #endif 00108