Image.h

Go to the documentation of this file.
00001 #ifndef X3DTK_IMAGE_H
00002 #define X3DTK_IMAGE_H
00003 
00004 #include "Platform.h"
00005 
00006 #include <limits>
00007 
00008 #undef max
00009 
00010 namespace X3DTK {
00011 
00012 class Image;
00013 
00014 template<class T>
00015 struct Memory
00016 {
00017   inline static T *access(Image *I, unsigned short x, unsigned short y);
00018 };
00019 
00020 template<class IT, class OT>
00021 struct ImageConverter
00022 {
00023   static void make(unsigned char *out, unsigned char *in, unsigned int length);
00024 };
00025 
00034 class Image
00035 {
00036 public:
00038   Image();
00040   Image(const char *fileName);
00042   ~Image();
00043   
00045   inline bool isLoaded() const {return (_data != 0);};
00047   void saveAs(const char *fileName, float quality = 1.0f);
00049   void resize(unsigned short width, unsigned short height, GLenum GLType = GL_NONE);
00051   unsigned char *resizeData(unsigned short width, unsigned short height, GLenum GLType = GL_NONE);
00054   void resizeGL(float (& textureTransform)[16]);
00056   bool allocate(unsigned short width, unsigned short height, GLenum GLFormat, GLenum GLType);
00058   void release();
00059   
00061   inline unsigned short getWidth() const {return _width;};
00063   inline unsigned short getHeight() const {return _height;};
00065   inline GLenum getGLFormat() const {return _glFormat;};
00067   inline GLenum getGLType() const {return _type;};
00069   inline int getPixelSize() const;
00071   inline unsigned char* getData() const {return _data;};
00073   static int computePixelSize(GLenum GLFormat, GLenum GLType);  
00074 private:
00075   unsigned char *_data;
00076   GLenum _glFormat;    
00077   GLenum _type;
00078   unsigned short _width;
00079   unsigned short _height;
00080   
00081   void convert(GLenum oldType, GLenum newType, unsigned char *newData, unsigned char *data, unsigned int length);
00082 };
00083 
00084 }
00085 
00086 #include "Image.inl"
00087 
00088 #endif

Generated on Fri Aug 27 13:16:22 2004 for X3DToolKit by doxygen 1.3.6