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

panda/src/pnmimagetypes/pnmFileTypeJPG2000.h

Go to the documentation of this file.
00001 // Filename: pnmFileTypeJPG2000.h
00002 // Created by:  mike (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 PNMFILETYPEJPG2000_H
00020 #define PNMFILETYPEJPG2000_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "pnmFileType.h"
00025 #include "pnmReader.h"
00026 #include "pnmWriter.h"
00027 
00028 #if defined(_WIN32)
00029 #include <windows.h>  // we need to include this before jpeglib.
00030 #endif
00031 
00032 #include "typedef.h"  // jasper requires this first.
00033 #include <jasper/jasper.h>
00034 
00035 // Undo jasper-inflicted damage.
00036 #undef bool
00037 
00038 ////////////////////////////////////////////////////////////////////
00039 //       Class : PNMFileTypeJPG2000
00040 // Description : For reading and writing Jpeg2000 files.
00041 ////////////////////////////////////////////////////////////////////
00042 class EXPCL_PANDA PNMFileTypeJPG2000 : public PNMFileType {
00043 public:
00044   PNMFileTypeJPG2000();
00045 
00046   virtual string get_name() const;
00047 
00048   virtual int get_num_extensions() const;
00049   virtual string get_extension(int n) const;
00050   virtual string get_suggested_extension() const;
00051 
00052   virtual bool has_magic_number() const;
00053   virtual bool matches_magic_number(const string &magic_number) const;
00054 
00055   virtual PNMReader *make_reader(istream *file, bool owns_file = true,
00056                                  const string &magic_number = string());
00057   virtual PNMWriter *make_writer(ostream *file, bool owns_file = true);
00058 
00059 public:
00060   class Reader : public PNMReader {
00061   public:
00062     Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number);
00063     ~Reader(void);
00064 
00065     virtual int read_data(xel *array, xelval *alpha);
00066 
00067   private:
00068 /*
00069     // struct jpeg_decompress_struct _cinfo;
00070     jas_image_t *image;
00071     jas_stream_t *in;
00072     jas_stream_t *out;
00073 */  
00074 
00075 
00076     struct my_error_mgr {
00077       struct jpeg_error_mgr pub;
00078       jmp_buf setjmp_buffer;
00079     };
00080     typedef struct my_error_mgr *_my_error_ptr;
00081     struct my_error_mgr _jerr;
00082     unsigned long       pos;
00083 
00084     unsigned long offBits;
00085 
00086     unsigned short  cBitCount;
00087     int             indexed;
00088     int             classv;
00089 
00090     pixval R[256];      /* reds */
00091     pixval G[256];      /* greens */
00092     pixval B[256];      /* blues */
00093   };
00094 
00095   class Writer : public PNMWriter {
00096   public:
00097     Writer(PNMFileType *type, ostream *file, bool owns_file);
00098 
00099     virtual int write_data(xel *array, xelval *alpha);
00100   };
00101 
00102 
00103   // The TypedWritable interface follows.
00104 public:
00105   static void register_with_read_factory();
00106 
00107 protected:
00108   static TypedWritable *make_PNMFileTypeJPG2000(const FactoryParams &params);
00109 
00110 public:
00111   static TypeHandle get_class_type() {
00112     return _type_handle;
00113   }
00114   static void init_type() {
00115     PNMFileType::init_type();
00116     register_type(_type_handle, "PNMFileTypeJPG2000",
00117                   PNMFileType::get_class_type());
00118   }
00119   virtual TypeHandle get_type() const {
00120     return get_class_type();
00121   }
00122   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00123 
00124 private:
00125   static TypeHandle _type_handle;
00126 };
00127 
00128 #endif
00129 
00130 

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