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

Image.h

Go to the documentation of this file.
00001 
00040 #ifndef _AMIRE_COMMON_IMAGE_H
00041 #define _AMIRE_COMMON_IMAGE_H
00042 
00043 #include <amire/common/Defines.h>
00044 
00045 #include <amire/common/Updateable.h>
00046 #include <amire/common/BitmapFormat.h>
00047 
00048 namespace amire {
00049   namespace common {
00050     class ImageLoader;
00051 
00055     class AMIRE_EXPORT_API Image : public virtual Updateable {
00056     protected:
00060       int width;
00061 
00065       int height;
00066 
00070       BitmapFormat format;
00071 
00075       long bufferSize;
00076 
00080       unsigned char *data;
00081 
00085       bool deleteData;
00086 
00090       bool horizontalFlip;
00091 
00095       bool verticalFlip;
00096 
00100       long imageId;
00101 
00102     public:
00106       Image(int width = 0, int height = 0, BitmapFormat format= RGB, long bufferSize = 0, unsigned char *data = NULL, bool deleteData = true);
00107 
00108       virtual ~Image();
00109 
00113       inline int getWidth() const {
00114         return width;
00115       }
00116 
00120       inline int getHeight() const {
00121         return height;
00122       }
00123 
00127       inline BitmapFormat getFormat() const {
00128         return format;
00129       }
00130 
00134       inline long getBufferSize() const {
00135         return bufferSize;
00136       }
00137 
00141       inline long getBytesPerPixel() const {
00142         int pixels = width * height;
00143           return (pixels) ? bufferSize / pixels : 0;
00144       }
00145 
00149       inline unsigned char *getData() const {
00150         return data;
00151       }
00152 
00156       inline long getImageId() const {
00157         return imageId;
00158       }
00159 
00163       inline void setHorizontalFlip(bool horizontalFlip){
00164         this->horizontalFlip = horizontalFlip;
00165       }
00166 
00170       inline void setVerticalFlip(bool verticalFlip) {
00171         this->verticalFlip = verticalFlip;
00172       }
00173 
00177       inline bool getHorizontalFlip() const {
00178         return horizontalFlip;
00179       }
00180 
00184       inline bool getVerticalFlip() const {
00185         return verticalFlip;
00186       }
00187 
00188     protected:
00192       virtual void doUpdate();
00193 
00197       void flipImage(bool horizontal, bool vertical);
00198     };
00199 
00203     class AMIRE_EXPORT_API ImageBackground : public virtual osg::Referenced {
00204     protected:
00208       osg::ref_ptr<Image> image;
00209 
00213       int bufferSize;
00214 
00218       unsigned char *buffer;
00219 
00223       bool mirrorHorizonal;
00224 
00228       bool mirrorVertical;
00229 
00233       bool useGLDimension;
00234 
00238       int imageId;
00239 
00240     public:
00244       ImageBackground(const osg::ref_ptr<Image> &image = NULL, bool mirrorHorizonal = false, bool mirrorVertical = false, bool useGLDimension = false);
00245 
00249       void draw(int viewPortX, int viewPortY, int viewPortWidth, int viewPortHeight, bool convertToRGB = false);
00250 
00254       void setImage(const osg::ref_ptr<Image> &image);
00255     };
00256 
00260     class AMIRE_EXPORT_API ImageTexture : public virtual osg::Referenced {
00261     protected:
00265       osg::ref_ptr<Image> image;
00266 
00270       int glWidth;
00271 
00275       int glHeight;
00276 
00280       int wrapS;
00281 
00285       int wrapT;
00286 
00290       int magnification;
00291 
00295       int minification;
00296 
00300       int internalFormat;
00301 
00305       long imageId;
00306 
00310       bool manageUnbind;
00311 
00315       bool bound;
00316 
00320       bool updateTexture;
00321 
00325       unsigned int textureId;
00326 
00327     public:
00331       ImageTexture(bool manageUnbind = true, int wrapS = GL_CLAMP, int wrapT = GL_CLAMP, int magnification = GL_LINEAR, int minification = GL_LINEAR);
00332 
00336       ImageTexture(const osg::ref_ptr<Image> &image, bool manageUnbind = true, int wrapS = GL_CLAMP, int wrapT = GL_CLAMP, int magnification = GL_LINEAR, int minification = GL_LINEAR);
00337 
00341       ImageTexture(const ImageTexture &texture);
00342 
00346       virtual ~ImageTexture();
00347 
00351       ImageTexture &operator =(const ImageTexture &texture);
00352 
00356       bool isBound();
00357 
00361       int glBind();
00362 
00366       int glBind(int internalFormat);
00367 
00371       int glApply();
00372 
00376       int glApply(GLint param);
00377 
00381       inline int getGlWidth() const {
00382         return glWidth;
00383       }
00384 
00388       inline int getGlHeight() const {
00389         return glHeight;
00390       }
00391 
00395       inline int getWrapS() const {
00396         return wrapS;
00397       }
00398 
00402       inline int getWrapT() const {
00403         return wrapT;
00404       }
00405 
00409       inline int getMagnification() const {
00410         return magnification;
00411       }
00412 
00416       inline int getMinification() const {
00417         return minification;
00418       }
00419 
00423       inline void setImage(osg::ref_ptr<Image> image) {
00424         this->image = image;
00425         updateTexture = true;
00426       }
00427 
00431       inline void setWrapS(int wrapS) {
00432         this->wrapS = wrapS;
00433         updateTexture = true;
00434       }
00435 
00439       inline void setWrapT(int wrapT) {
00440         this->wrapT = wrapT;
00441         updateTexture = true;
00442       }
00443 
00447       inline void setMagnification(int magnification) {
00448         this->magnification = magnification;
00449         updateTexture = true;
00450       }
00451 
00455       inline const osg::ref_ptr<Image> &getImage() const {
00456         return image;
00457       }
00458 
00462       inline void setMinification(int minification) {
00463         this->minification = minification;
00464         updateTexture = true;
00465       }
00466     };
00467   }
00468 }
00469 #endif

Generated on Tue May 20 17:23:52 2003 for AMIRE-Framework by doxygen1.3