wxImage.
More...
#include <imagecommon.h>

Public Member Functions | |
| ImageCommon () | |
| Class constructor. | |
| virtual | ~ImageCommon () |
| Class destructor. | |
| virtual bool | IsOk () const |
Is image properly loaded? - Image overload. | |
| virtual bool | Load (const wxString &fname) |
Load image data from file - Image overload. | |
| virtual GLuint | BuildOglTexture () const |
| virtual bool | HasTransparency () const |
Get true if image has alpha channel - Image overload. | |
| virtual int | GetWidth () const |
| Get the widht of the image. | |
| virtual int | GetHeight () const |
| Get the height of the image. | |
Protected Attributes | |
| wxImage * | image |
wxImage instance | |
wxImage.
Definition at line 23 of file imagecommon.h.
| ImageCommon::ImageCommon | ( | ) |
| ImageCommon::~ImageCommon | ( | ) | [virtual] |
Class destructor.
Definition at line 24 of file imagecommon.cpp.
00025 { 00026 SAFE_DELETE(image); 00027 }
| bool ImageCommon::IsOk | ( | ) | const [virtual] |
Is image properly loaded? - Image overload.
Implements VRUT::Image.
Definition at line 30 of file imagecommon.cpp.
| bool ImageCommon::Load | ( | const wxString & | fname | ) | [virtual] |
Load image data from file - Image overload.
Reimplemented from VRUT::Image.
Definition at line 36 of file imagecommon.cpp.
00037 { 00038 if (Image::Load(fname)) 00039 { 00040 wxImage im(fname); 00041 if (im.IsOk()) 00042 { 00043 SAFE_DELETE(image); 00044 image = new wxImage(im.Mirror(false)); 00045 return true; 00046 } 00047 } 00048 return false; 00049 }
| GLuint ImageCommon::BuildOglTexture | ( | ) | const [virtual] |
Build and bind OpenGL texture from image in CURRENT OpenGL context - Image overload
GL_ID_NONE if failed Join RGB and Alpha data
Implements VRUT::Image.
Definition at line 52 of file imagecommon.cpp.
00053 { 00054 GLuint texID = GL_ID_NONE; 00055 if (IsOk()) 00056 { 00057 glEnable(GL_TEXTURE_2D); 00058 glGenTextures( 1, &texID ); 00059 glBindTexture( GL_TEXTURE_2D, texID ); 00060 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); 00061 glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE ); 00062 if (image->HasAlpha()) 00063 { 00065 unsigned pixels = image->GetWidth() * image->GetHeight(); 00066 GLubyte * rgbaData = new GLubyte[pixels * 4]; 00067 unsigned char * tmpRGBA = rgbaData; 00068 unsigned char * rgbData = image->GetData(); 00069 unsigned char * alphaData = image->GetAlpha(); 00070 for (unsigned pix = 0; pix < pixels; pix++) 00071 { 00072 *tmpRGBA++ = *rgbData++; 00073 *tmpRGBA++ = *rgbData++; 00074 *tmpRGBA++ = *rgbData++; 00075 *tmpRGBA++ = *alphaData++; 00076 } 00077 gluBuild2DMipmaps(GL_TEXTURE_2D, 00078 4, 00079 image->GetWidth(), 00080 image->GetHeight(), 00081 GL_RGBA, 00082 GL_UNSIGNED_BYTE, 00083 rgbaData); 00084 delete [] rgbaData; 00085 } 00086 else 00087 gluBuild2DMipmaps(GL_TEXTURE_2D, 00088 3, 00089 image->GetWidth(), 00090 image->GetHeight(), 00091 GL_RGB, 00092 GL_UNSIGNED_BYTE, 00093 image->GetData()); 00094 } 00095 return texID; 00096 }
| bool ImageCommon::HasTransparency | ( | ) | const [virtual] |
Get true if image has alpha channel - Image overload.
Implements VRUT::Image.
Definition at line 99 of file imagecommon.cpp.
| int ImageCommon::GetWidth | ( | ) | const [virtual] |
| int ImageCommon::GetHeight | ( | ) | const [virtual] |
Get the height of the image.
Implements VRUT::Image.
Definition at line 109 of file imagecommon.cpp.
wxImage* VRUT::ImageCommon::image [protected] |
1.5.5