Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

image.cpp

Go to the documentation of this file.
00001 #include "image.h"
00002 
00003 using namespace kerosin;
00004 
00005 // constructor
00006 Image::Image()
00007 {
00008     // let's create a DevIL ID for this image
00009     ilGenImages(1, &mId);
00010 }
00011 
00012 // destructor
00013 Image::~Image()
00014 {
00015     // free the image with DevIL
00016     ilDeleteImages(1, &mId);
00017 }
00018 
00019 void Image::Bind()
00020 {
00021     ilBindImage(mId);
00022 }
00023 
00024 ILuint Image::Width()
00025 {
00026     Bind();
00027     return ilGetInteger(IL_IMAGE_WIDTH);
00028 }
00029 
00030 
00031 ILuint Image::Height()
00032 {
00033     Bind();
00034     return ilGetInteger(IL_IMAGE_HEIGHT);
00035 }
00036 
00037 
00038 ILuint Image::Depth()
00039 {
00040     Bind();
00041     return ilGetInteger(IL_IMAGE_DEPTH);
00042 }
00043 
00044 ILuint Image::BitsPP()
00045 {
00046     Bind();
00047     return ilGetInteger(IL_IMAGE_BITS_PER_PIXEL );
00048 }
00049 
00050 ILuint Image::BytesPP()
00051 {
00052     Bind();
00053     return ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL );
00054 }
00055 
00056 ILuint Image::Type()
00057 {
00058     Bind();
00059     return ilGetInteger(IL_IMAGE_TYPE);
00060 }
00061 
00062 ILuint Image::Format()
00063 {
00064     Bind();
00065     return ilGetInteger(IL_IMAGE_FORMAT);
00066 }
00067 
00068 ILubyte* Image::Data()
00069 {
00070     Bind();
00071     return ilGetData();
00072 }
00073 
00074 bool Image::HasAlpha()
00075 {
00076     Bind();
00077     ILuint format = Format();
00078 
00079     switch(format)
00080     {
00081     case IL_RGB:
00082     case IL_BGR:
00083         return false;
00084         break;
00085     case IL_RGBA:
00086     case IL_BGRA:
00087         return true;
00088         break;
00089     default:
00090         return false;
00091     }
00092 }
00093 
00094 
00095 bool Image::Create(int w, int h, int b, void *data)
00096 {
00097     Bind();
00098     
00099     if(b==3)
00100     {
00101         ilTexImage(w, h, 1, b, IL_RGB, IL_UNSIGNED_BYTE, data);
00102     }
00103     else
00104     {
00105         ilTexImage(w, h, 1, b, IL_RGBA, IL_UNSIGNED_BYTE, data);
00106     }
00107     return true;
00108 }

Generated on Thu Apr 6 15:25:38 2006 for rcssserver3d by  doxygen 1.4.4