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