Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/pnmimagetypes/pnmFileTypeBMP.h

Go to the documentation of this file.
00001 // Filename: pnmFileTypeBMP.h
00002 // Created by:  drose (17Jun00)
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 PNMFILETYPEBMP_H
00020 #define PNMFILETYPEBMP_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "pnmFileType.h"
00025 #include "pnmReader.h"
00026 #include "pnmWriter.h"
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //       Class : PNMFileTypeBMP
00030 // Description : For reading and writing Windows BMP files.
00031 ////////////////////////////////////////////////////////////////////
00032 class EXPCL_PANDA PNMFileTypeBMP : public PNMFileType {
00033 public:
00034   PNMFileTypeBMP();
00035 
00036   virtual string get_name() const;
00037 
00038   virtual int get_num_extensions() const;
00039   virtual string get_extension(int n) const;
00040   virtual string get_suggested_extension() const;
00041 
00042   virtual bool has_magic_number() const;
00043   virtual bool matches_magic_number(const string &magic_number) const;
00044 
00045   virtual PNMReader *make_reader(istream *file, bool owns_file = true,
00046                                  const string &magic_number = string());
00047   virtual PNMWriter *make_writer(ostream *file, bool owns_file = true);
00048 
00049 public:
00050   class Reader : public PNMReader {
00051   public:
00052     Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number);
00053 
00054     virtual int read_data(xel *array, xelval *alpha);
00055 
00056   private:
00057     unsigned long       pos;
00058 
00059     unsigned long offBits;
00060 
00061     unsigned short  cBitCount;
00062     int             indexed;
00063     int             classv;
00064 
00065     pixval R[256];      /* reds */
00066     pixval G[256];      /* greens */
00067     pixval B[256];      /* blues */
00068   };
00069 
00070   class Writer : public PNMWriter {
00071   public:
00072     Writer(PNMFileType *type, ostream *file, bool owns_file);
00073 
00074     virtual int write_data(xel *array, xelval *alpha);
00075   };
00076 
00077 
00078   // The TypedWritable interface follows.
00079 public:
00080   static void register_with_read_factory();
00081 
00082 protected:
00083   static TypedWritable *make_PNMFileTypeBMP(const FactoryParams &params);
00084 
00085 public:
00086   static TypeHandle get_class_type() {
00087     return _type_handle;
00088   }
00089   static void init_type() {
00090     PNMFileType::init_type();
00091     register_type(_type_handle, "PNMFileTypeBMP",
00092                   PNMFileType::get_class_type());
00093   }
00094   virtual TypeHandle get_type() const {
00095     return get_class_type();
00096   }
00097   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00098 
00099 private:
00100   static TypeHandle _type_handle;
00101 };
00102 
00103 #endif
00104 
00105 

Generated on Fri May 2 00:43:14 2003 for Panda by doxygen1.3