From: Oliver O. <fr...@us...> - 2006-03-08 09:19:03
|
Update of /cvsroot/simspark/simspark/spark/kerosin/imageserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3651/imageserver Modified Files: image.cpp image.h imageserver.cpp imageserver.h imageserver_c.cpp Log Message: - changed the ImageServer so that it compiles without DevIL. For this, some DevIL types had to be encapsulated in the kerosin::Image and kerosin::ImageServer classes. Advantage of this method (over not compiling the ImageServer at all when DevIL is not present) is that checks for the ImageServer are not necessary in code using kerosin. - the ImageServer interface has been changed to be const-correct and to provide interface functions with standard types only (or types defined in kerosin and salt). Index: imageserver.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/imageserver/imageserver.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** imageserver.cpp 5 Dec 2005 21:38:22 -0000 1.1 --- imageserver.cpp 8 Mar 2006 09:18:56 -0000 1.2 *************** *** 33,52 **** using namespace std; shared_ptr<FileServer> gFileServer; ! //------------------------------------------------------------------------------------------------ ! // FileServer hooks for DevIL ! //------------------------------------------------------------------------------------------------ ! ILHANDLE ILAPIENTRY FSOpen(const ILstring inName) { return (ILHANDLE)(gFileServer->Register(inName)); } ! ILvoid ILAPIENTRY FSClose(ILHANDLE handle) { gFileServer->Close((FileServer::THandle)handle); } ! ILboolean ILAPIENTRY FSEof(ILHANDLE handle) { shared_ptr<salt::RFile> file = --- 33,56 ---- using namespace std; + #if HAVE_IL_IL_H + //----------------------------------------------------------------------------- + // FileServer hooks for DevIL + //----------------------------------------------------------------------------- shared_ptr<FileServer> gFileServer; ! ILHANDLE ! ILAPIENTRY FSOpen(const ILstring inName) { return (ILHANDLE)(gFileServer->Register(inName)); } ! ILvoid ! ILAPIENTRY FSClose(ILHANDLE handle) { gFileServer->Close((FileServer::THandle)handle); } ! ILboolean ! ILAPIENTRY FSEof(ILHANDLE handle) { shared_ptr<salt::RFile> file = *************** *** 56,62 **** } ! ILint ILAPIENTRY FSGetc(ILHANDLE handle) { ! shared_ptr<salt::RFile> file = gFileServer->Get((FileServer::THandle)handle); --- 60,67 ---- } ! ILint ! ILAPIENTRY FSGetc(ILHANDLE handle) { ! shared_ptr<salt::RFile> file = gFileServer->Get((FileServer::THandle)handle); *************** *** 64,68 **** } ! ILint ILAPIENTRY FSRead(void *buffer, ILuint size, ILuint count, ILHANDLE handle) { shared_ptr<salt::RFile> file = --- 69,74 ---- } ! ILint ! ILAPIENTRY FSRead(void *buffer, ILuint size, ILuint count, ILHANDLE handle) { shared_ptr<salt::RFile> file = *************** *** 72,76 **** } ! ILint ILAPIENTRY FSSeek(ILHANDLE handle, ILint offset, ILint origin) { shared_ptr<salt::RFile> file = --- 78,83 ---- } ! ILint ! ILAPIENTRY FSSeek(ILHANDLE handle, ILint offset, ILint origin) { shared_ptr<salt::RFile> file = *************** *** 80,84 **** } ! ILint ILAPIENTRY FSTell(ILHANDLE handle) { shared_ptr<salt::RFile> file = --- 87,92 ---- } ! ILint ! ILAPIENTRY FSTell(ILHANDLE handle) { shared_ptr<salt::RFile> file = *************** *** 87,90 **** --- 95,99 ---- return file->Tell(); } + #endif // HAVE_IL_IL_H //------------------------------------------------------------------------------------------------ *************** *** 95,98 **** --- 104,108 ---- ImageServer::ImageServer() { + #if HAVE_IL_IL_H // initialize DevIL ilInit(); *************** *** 105,124 **** // register FileServer hooks for DevIL ! ilSetRead( ! FSOpen, ! FSClose, ! FSEof, ! FSGetc, ! FSRead, ! FSSeek, ! FSTell); } // ! // This function loads the file inName. If inType is IL_TYPE_UNKNOWN, // then the library will try to find a handler by the file extension provided. // This behavior is done automatically by the library! // ! boost::shared_ptr<Image> ImageServer::Load(const string& inName, ILenum inType) { // create a new image --- 115,133 ---- // register FileServer hooks for DevIL ! ilSetRead(FSOpen, FSClose, FSEof, FSGetc, FSRead, FSSeek, FSTell); ! #else ! #warning ====================================================================== ! #warning The ImageServer is will not work properly without using DevIL ! #warning ====================================================================== ! #endif } // ! // This function loads the file inName. If inType is eTYPE_UNKNOWN, // then the library will try to find a handler by the file extension provided. // This behavior is done automatically by the library! // ! boost::shared_ptr<Image> ! ImageServer::Load(const string& inName, ImageServer::EImgType inType) const { // create a new image *************** *** 130,151 **** // set the file server gFileServer = shared_static_cast<FileServer>(GetCore()->Get("/sys/server/file")); ! // load the image ilLoad(inType, (ILstring)inName.c_str()); ! // set the file server to 0 again gFileServer.reset(); // check for errors ! if(HandleErrors() == true) ! { ! // release the image and return ! return boost::shared_ptr<Image>(); ! } return image; } ! bool ImageServer::Save(const boost::shared_ptr<Image> &inImage, const string& inName, ILenum inType) { // make the image active --- 139,167 ---- // set the file server gFileServer = shared_static_cast<FileServer>(GetCore()->Get("/sys/server/file")); ! #if HAVE_IL_IL_H // load the image ilLoad(inType, (ILstring)inName.c_str()); ! #else ! GetLog()->Error() << "(ImageServer) ERROR: Sorry, SPARK was compiled " ! << "without image support.\n" ! << " To support loading images, " ! << "install DevIL (http://openil.sf.net/) and recompile SPARK.\n"; ! #endif // set the file server to 0 again gFileServer.reset(); // check for errors ! if (HandleErrors() == true) ! { ! // release the image and return ! return boost::shared_ptr<Image>(); ! } return image; } ! bool ! ImageServer::Save(boost::shared_ptr<Image> inImage, const string& inName, ! ImageServer::EImgType inType) const { // make the image active *************** *** 155,160 **** --- 171,183 ---- gFileServer = shared_static_cast<FileServer>(GetCore()->Get("/sys/server/file")); + #if HAVE_IL_IL_H // save the image ilSave(inType, (ILstring)inName.c_str()); + #else + GetLog()->Error() << "(ImageServer) ERROR: Sorry, SPARK was compiled " + << "without image support.\n" + << " To support loading images, " + << "install DevIL (http://openil.sf.net/) and recompile SPARK.\n"; + #endif // set the file server to 0 again *************** *** 162,179 **** // check for errors ! if(HandleErrors() == true) ! { ! return false; ! } return true; } ! // ! // This routine checks for DevIL errors and logs them. The function returns ! // 'true' if an error has occured and 'false' if not. ! // ! bool ImageServer::HandleErrors() { bool ret = false; ILenum error; --- 185,202 ---- // check for errors ! if (HandleErrors() == true) ! { ! return false; ! } return true; } ! // This routine checks for DevIL errors and logs them. The function returns ! // 'true' if an error has occured and 'false' if not. ! bool ! ImageServer::HandleErrors() const { + #if HAVE_IL_IL_H bool ret = false; ILenum error; *************** *** 181,293 **** // check if we have any errors and log them accordingly while ((error = ilGetError()) != IL_NO_ERROR) ! { ! ret = true; ! ! string msg; ! switch(error) ! { ! case IL_INVALID_ENUM : ! msg = "invalid enum"; ! break; ! case IL_OUT_OF_MEMORY : ! msg = "out of memory"; ! break; ! case IL_FORMAT_NOT_SUPPORTED : ! msg = "format not supported"; ! break; ! case IL_INTERNAL_ERROR : ! msg = "internal error"; ! break; ! case IL_INVALID_VALUE : ! msg = "invalid value"; ! break; ! case IL_ILLEGAL_OPERATION : ! msg = "illegal operation"; ! break; ! case IL_ILLEGAL_FILE_VALUE : ! msg = "illegal file value"; ! break; ! case IL_INVALID_FILE_HEADER : ! msg = "invalid file header"; ! break; ! case IL_INVALID_PARAM : ! msg = "invalid param"; ! break; ! case IL_COULD_NOT_OPEN_FILE : ! msg = "could not open file"; ! break; ! case IL_INVALID_EXTENSION : ! msg = "invalid extension"; ! break; ! case IL_FILE_ALREADY_EXISTS : ! msg = "file already exists"; ! break; ! case IL_OUT_FORMAT_SAME : ! msg = "out format same"; ! break; ! case IL_STACK_OVERFLOW : ! msg ="stack overflow"; ! break; ! case IL_STACK_UNDERFLOW : ! msg ="stack underflow"; ! break; ! case IL_INVALID_CONVERSION : ! msg = "invalid conversion"; ! break; ! case IL_BAD_DIMENSIONS : ! msg = "bad dimensions"; ! break; ! case IL_FILE_READ_ERROR : ! //case IL_FILE_WRITE_ERROR : ! msg = "file read/write error"; ! break; ! case IL_LIB_GIF_ERROR : ! msg = "lib gif error"; ! break; ! case IL_LIB_JPEG_ERROR : ! msg = "lib jpeg error"; ! break; ! case IL_LIB_PNG_ERROR : ! msg = "lib png error"; ! break; ! case IL_LIB_TIFF_ERROR : ! msg = "lib tiff error"; ! break; ! case IL_LIB_MNG_ERROR : ! msg = "lib mng error"; ! break; ! default: ! msg = "unknown IL error"; ! break; ! } ! GetLog()->Error() << "(ImageServer) ERROR: DevIL returned error " ! << error << " (" << msg << ")\n"; } return ret; } --- 204,319 ---- // check if we have any errors and log them accordingly while ((error = ilGetError()) != IL_NO_ERROR) ! { ! ret = true; ! string msg; ! switch(error) ! { ! case IL_INVALID_ENUM : ! msg = "invalid enum"; ! break; ! case IL_OUT_OF_MEMORY : ! msg = "out of memory"; ! break; ! case IL_FORMAT_NOT_SUPPORTED : ! msg = "format not supported"; ! break; ! case IL_INTERNAL_ERROR : ! msg = "internal error"; ! break; ! case IL_INVALID_VALUE : ! msg = "invalid value"; ! break; ! case IL_ILLEGAL_OPERATION : ! msg = "illegal operation"; ! break; ! case IL_ILLEGAL_FILE_VALUE : ! msg = "illegal file value"; ! break; ! case IL_INVALID_FILE_HEADER : ! msg = "invalid file header"; ! break; ! case IL_INVALID_PARAM : ! msg = "invalid param"; ! break; ! case IL_COULD_NOT_OPEN_FILE : ! msg = "could not open file"; ! break; ! case IL_INVALID_EXTENSION : ! msg = "invalid extension"; ! break; ! case IL_FILE_ALREADY_EXISTS : ! msg = "file already exists"; ! break; ! case IL_OUT_FORMAT_SAME : ! msg = "out format same"; ! break; ! case IL_STACK_OVERFLOW : ! msg ="stack overflow"; ! break; ! case IL_STACK_UNDERFLOW : ! msg ="stack underflow"; ! break; ! case IL_INVALID_CONVERSION : ! msg = "invalid conversion"; ! break; ! case IL_BAD_DIMENSIONS : ! msg = "bad dimensions"; ! break; ! case IL_FILE_READ_ERROR : ! //case IL_FILE_WRITE_ERROR : ! msg = "file read/write error"; ! break; ! case IL_LIB_GIF_ERROR : ! msg = "lib gif error"; ! break; ! case IL_LIB_JPEG_ERROR : ! msg = "lib jpeg error"; ! break; ! case IL_LIB_PNG_ERROR : ! msg = "lib png error"; ! break; ! case IL_LIB_TIFF_ERROR : ! msg = "lib tiff error"; ! break; ! case IL_LIB_MNG_ERROR : ! msg = "lib mng error"; ! break; ! default: ! msg = "unknown IL error"; ! break; } + GetLog()->Error() << "(ImageServer) ERROR: DevIL returned error " + << error << " (" << msg << ")\n"; + } + return ret; + #else + return true; + #endif } Index: imageserver.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/imageserver/imageserver.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** imageserver.h 5 Dec 2005 21:38:22 -0000 1.1 --- imageserver.h 8 Mar 2006 09:18:56 -0000 1.2 *************** *** 23,27 **** --- 23,33 ---- #define KEROSIN_IMAGESERVER_H + #ifdef HAVE_CONFIG_H + #include <config.h> + #endif + #ifdef HAVE_IL_IL_H #include <IL/il.h> + #endif + #include <zeitgeist/class.h> *************** *** 39,65 **** - Conversion between formats ! NOTE: ! ! HISTORY: ! 14.07.01 - MK ! - Initial version ! 29.07.01 - MK ! - Uses classserver ! 29.08.01 - MK ! - Doesn't use classserver anymore :( ! - Switched to DevIL for image loading needs, since the task of supporting ! all major formats would have been too time consuming ! - Cleaned up the interface of the imageserver quite a bit ! 11.10.01 - MK ! - Made singleton functionality more secure ! 02.10.02 - MK ! - Moved to Kerosin ! ! TODO: ! - Image creation ! - Image conversion ! - Pixel-level access ! TOFIX: */ --- 45,54 ---- - Conversion between formats ! NOTE: Initial version 14.07.01 - MK ! TODO: ! - Image creation ! - Image conversion ! - Pixel-level access */ *************** *** 67,85 **** { public: ImageServer(); // load/save ! /** interpret the file with the filter associated with inExt */ boost::shared_ptr<Image> Load(const std::string& inName, ! ILenum inType = IL_TYPE_UNKNOWN); ! /** interpret the file with the filter associated with inExt */ ! bool Save(const boost::shared_ptr<Image> &inImage, const std::string& inName, ! ILenum inType = IL_TYPE_UNKNOWN); private: ! /** some internal error checking */ ! bool HandleErrors(); }; --- 56,144 ---- { public: + #ifdef HAVE_IL_IL_H + enum EImgType + { + eTYPE_UNKNOWN = IL_TYPE_UNKNOWN, + eBMP = IL_BMP, + eCUT = IL_CUT, + eDOOM = IL_DOOM, + eDOOM_FLAT = IL_DOOM_FLAT, + eICO = IL_ICO, + eJPG = IL_JPG, + eJFIF = IL_JFIF, + eLBM = IL_LBM, + ePCD = IL_PCD, + ePCX = IL_PCX, + ePIC = IL_PIC, + ePNG = IL_PNG, + ePNM = IL_PNM, + eSGI = IL_SGI, + eTGA = IL_TGA, + eTIF = IL_TIF, + eCHEAD = IL_CHEAD, + eRAW = IL_RAW, + eMDL = IL_MDL, + eWAL = IL_WAL, + eLIF = IL_LIF, + eMNG = IL_MNG, + eJNG = IL_JNG, + eGIF = IL_GIF, + eDDS = IL_DDS, + eDCX = IL_DCX, + ePSD = IL_PSD, + eEXIF = IL_EXIF, + ePSP = IL_PSP, + ePIX = IL_PIX, + ePXR = IL_PXR, + eXPM = IL_XPM, + eHDR = IL_HDR, + eJASC_PAL = IL_JASC_PAL + }; + #else + enum EImgType + { + eTYPE_UNKNOWN, eBMP, eCUT, eDOOM, + eDOOM_FLAT, eICO, eJPG, eJFIF, + eLBM, ePCD, ePCX, ePIC, + ePNG, ePNM, eSGI, eTGA, + eTIF, eCHEAD, eRAW, eMDL, + eWAL, eLIF, eMNG, eJNG, + eGIF, eDDS, eDCX, ePSD, + eEXIF, ePSP, ePIX, ePXR, + eXPM, eHDR, eJASC_PAL + }; + #endif + public: ImageServer(); // load/save ! /** Load the file with the filter associated with the given type. ! If inType is eTYPE_UNKNOWN, then Load try to find a handler by the ! file extension provided. If using DevIL, this behavior is done ! automatically by the library (Without DevIL, loading and saving ! is disabled at the moment). ! @param inName the file name of the image ! @param inType hint for the file type ! @return a shared_ptr to the Image (handle) ! */ boost::shared_ptr<Image> Load(const std::string& inName, ! EImgType inType = eTYPE_UNKNOWN) const; ! /** Save the file with the filter associated with the given type. ! @param inImage a shared_ptr to the image (handle) ! @param inName the name of the file for the image ! @param inType a hint for the file type ! @return true if successful ! */ ! bool Save(boost::shared_ptr<Image> inImage, const std::string& inName, ! EImgType inType = eTYPE_UNKNOWN) const; private: ! /** Some internal error checking. ! This routine checks for DevIL errors and logs them. ! @returns true if an error has occured and false if not. ! */ ! bool HandleErrors() const; }; Index: image.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/imageserver/image.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** image.cpp 5 Dec 2005 21:38:22 -0000 1.1 --- image.cpp 8 Mar 2006 09:18:56 -0000 1.2 *************** *** 1,2 **** --- 1,23 ---- + /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of simspark + Mon May 9 2005 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group + $Id$ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ #include "image.h" *************** *** 6,11 **** Image::Image() { ! // let's create a DevIL ID for this image ! ilGenImages(1, &mId); } --- 27,34 ---- Image::Image() { ! #ifdef HAVE_IL_IL_H ! // let's create a DevIL ID for this image ! ilGenImages(1, &mId); ! #endif } *************** *** 13,108 **** Image::~Image() { ! // free the image with DevIL ! ilDeleteImages(1, &mId); } ! void Image::Bind() { ! ilBindImage(mId); } ! ILuint Image::Width() { ! Bind(); ! return ilGetInteger(IL_IMAGE_WIDTH); } ! ! ILuint Image::Height() { ! Bind(); ! return ilGetInteger(IL_IMAGE_HEIGHT); } ! ! ILuint Image::Depth() { ! Bind(); ! return ilGetInteger(IL_IMAGE_DEPTH); } ! ILuint Image::BitsPP() { ! Bind(); ! return ilGetInteger(IL_IMAGE_BITS_PER_PIXEL ); } ! ILuint Image::BytesPP() { ! Bind(); ! return ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL ); } ! ILuint Image::Type() { ! Bind(); ! return ilGetInteger(IL_IMAGE_TYPE); } ! ILuint Image::Format() { ! Bind(); ! return ilGetInteger(IL_IMAGE_FORMAT); } ! ILubyte* Image::Data() { ! Bind(); ! return ilGetData(); } ! bool Image::HasAlpha() { ! Bind(); ! ILuint format = Format(); ! switch(format) ! { ! case IL_RGB: ! case IL_BGR: ! return false; ! break; ! case IL_RGBA: ! case IL_BGRA: ! return true; ! break; ! default: ! return false; ! } } ! bool Image::Create(int w, int h, int b, void *data) { ! Bind(); ! ! if(b==3) ! { ! ilTexImage(w, h, 1, b, IL_RGB, IL_UNSIGNED_BYTE, data); ! } ! else ! { ! ilTexImage(w, h, 1, b, IL_RGBA, IL_UNSIGNED_BYTE, data); ! } ! return true; } --- 36,183 ---- Image::~Image() { ! #ifdef HAVE_IL_IL_H ! // free the image with DevIL ! ilDeleteImages(1, &mId); ! #endif } ! void ! Image::Bind() const { ! #ifdef HAVE_IL_IL_H ! ilBindImage(mId); ! #endif } ! Image::TImgUInt ! Image::Width() const { ! #ifdef HAVE_IL_IL_H ! Bind(); ! return ilGetInteger(IL_IMAGE_WIDTH); ! #else ! return 0; ! #endif } ! Image::TImgUInt ! Image::Height() const { ! #ifdef HAVE_IL_IL_H ! Bind(); ! return ilGetInteger(IL_IMAGE_HEIGHT); ! #else ! return 0; ! #endif } ! Image::TImgUInt ! Image::Depth() const { ! #ifdef HAVE_IL_IL_H ! Bind(); ! return ilGetInteger(IL_IMAGE_DEPTH); ! #else ! return 0; ! #endif } ! Image::TImgUInt ! Image::BitsPP() const { ! #ifdef HAVE_IL_IL_H ! Bind(); ! return ilGetInteger(IL_IMAGE_BITS_PER_PIXEL ); ! #else ! return 0; ! #endif } ! Image::TImgUInt ! Image::BytesPP() const { ! #ifdef HAVE_IL_IL_H ! Bind(); ! return ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL ); ! #else ! return 0; ! #endif } ! Image::TImgUInt ! Image::Type() const { ! #ifdef HAVE_IL_IL_H ! Bind(); ! return ilGetInteger(IL_IMAGE_TYPE); ! #else ! return 0; ! #endif } ! Image::TImgUInt ! Image::Format() const { ! #ifdef HAVE_IL_IL_H ! Bind(); ! return ilGetInteger(IL_IMAGE_FORMAT); ! #else ! return 0; ! #endif } ! Image::TImgUChar* ! Image::Data() { ! #ifdef HAVE_IL_IL_H ! Bind(); ! return ilGetData(); ! #else ! return 0; ! #endif } ! bool ! Image::HasAlpha() const { ! #ifdef HAVE_IL_IL_H ! Bind(); ! TImgUInt format = Format(); ! switch(format) ! { ! case IL_RGB: ! case IL_BGR: ! return false; ! break; ! case IL_RGBA: ! case IL_BGRA: ! return true; ! break; ! default: ! return false; ! } ! #else ! return false; ! #endif } ! bool ! Image::Create(int w, int h, int b, void* data) { ! #ifdef HAVE_IL_IL_H ! Bind(); ! if (b==3) ! { ! ilTexImage(w, h, 1, b, IL_RGB, IL_UNSIGNED_BYTE, data); ! } ! else ! { ! ilTexImage(w, h, 1, b, IL_RGBA, IL_UNSIGNED_BYTE, data); ! } ! return true; ! #else ! return false; ! #endif } Index: imageserver_c.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/imageserver/imageserver_c.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** imageserver_c.cpp 5 Dec 2005 21:38:22 -0000 1.1 --- imageserver_c.cpp 8 Mar 2006 09:18:56 -0000 1.2 *************** *** 1,2 **** --- 1,23 ---- + /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of simspark + Mon May 9 2005 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group + $Id$ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ #include "imageserver.h" *************** *** 7,10 **** void CLASS(ImageServer)::DefineClass() { ! DEFINE_BASECLASS(zeitgeist/Leaf); } --- 28,31 ---- void CLASS(ImageServer)::DefineClass() { ! DEFINE_BASECLASS(zeitgeist/Leaf); } Index: image.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/imageserver/image.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** image.h 5 Dec 2005 21:38:22 -0000 1.1 --- image.h 8 Mar 2006 09:18:56 -0000 1.2 *************** *** 24,49 **** /* Image - A Wrapper for the DevIL Library ! NOTE: ! ! HISTORY: ! 11.07.01 - MK ! - Initial version ! 28.08.01 - MK ! - Added support for a palette ! 29.08.01 - MK ! - Rewrite for DevIL ! 03.09.01 - MK ! - OpenGL texture support ! TODO: - add RGB access - image creation - - TOFIX: */ ! #include <IL/il.h> namespace kerosin --- 24,41 ---- /* Image - A Wrapper for the DevIL Library + (or loading images by anything else) ! NOTE: Initial version by MK (11.07.01) TODO: - add RGB access - image creation */ ! #ifdef HAVE_CONFIG_H ! #include <config.h> ! #endif ! #ifdef HAVE_IL_IL_H #include <IL/il.h> + #endif namespace kerosin *************** *** 53,98 **** { public: ! // constructor/destructor Image(); virtual ~Image(); ! // this makes the image active ! void Bind(); // image information ! ILuint Width(); // width ! ILuint Height(); // height ! ILuint Depth(); // depth (==1 for 2d images, >1 for 3d images) ! ! ILuint BitsPP(); // bits per pixel ! ILuint BytesPP(); // bytes per pixel ! ! ILuint Type(); // format of pixels ! ILuint Format(); // byte format of image ! ! ILubyte*Data(); ! ! bool HasAlpha(); // does the format have an alpha channel ! bool Create(int w, int h, int b, void *data = NULL); ! // the interface functions ... these *have* to be implemented by derived classes ! //virtual bool Create() = 0; ! //virtual void SetPixel(int x, int y, long color) const = 0; ! //virtual long GetPixel(int x, int y) const = 0; ! /* ! virtual long MakeCol(int a, int r, int g, int b) const = 0; ! virtual void GetCol(long col, int& a, int& r, int& g, int& b) const = 0; ! virtual int GetA(long col) const = 0; ! virtual int GetR(long col) const = 0; ! virtual int GetG(long col) const = 0; ! virtual int GetB(long col) const = 0; - // accessors - f_inline void SetWidth (int inWidth) { mWidth = inWidth; } - f_inline void SetHeight(int inHeight) { mHeight = inHeight; } - */ protected: ! ILuint mId; // the DevIL ID which this image is bound to }; --- 45,90 ---- { public: ! #ifdef HAVE_IL_IL_H ! typedef ILuint TImgUInt; ! typedef ILubyte TImgUChar; ! #else ! typedef unsigned int TImgUInt; ! typedef unsigned char TImgUChar; ! #endif ! ! public: Image(); virtual ~Image(); ! //! this makes the image active ! void Bind() const; // image information ! //! @return the image width ! TImgUInt Width() const; ! //! @return the image height ! TImgUInt Height() const; ! /** Image depth information. ! @return 1 for 2d images, >1 for 3d images ! */ ! TImgUInt Depth() const; ! //! @return bits per pixel ! TImgUInt BitsPP() const; ! //! @return bytes per pixel ! TImgUInt BytesPP() const; ! //! @return format of pixels ! TImgUInt Type() const; ! //! @return byte format of image ! TImgUInt Format() const; ! TImgUChar* Data(); ! //! @return true if the format has an alpha channel ! bool HasAlpha() const; ! bool Create(int w, int h, int b, void* data = 0); protected: ! //! the (DevIL) ID which this image is bound to ! TImgUInt mId; }; |