CrystalSpace

Public API Reference

Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

imagebase.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005 by Jorrit Tyberghein
00003               (C) 2005 by Frank Richter
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00028 #ifndef __CS_CSGFX_IMAGEBASE_H__
00029 #define __CS_CSGFX_IMAGEBASE_H__
00030 
00031 #include "csextern.h"
00032 
00033 #include "csutil/databuf.h"
00034 
00035 #include "igraphic/image.h"
00036 
00037 
00043 class csImageBase : public iImage
00044 {
00045 protected:
00047   char* fName;
00049   csImageBase() : fName(0) { }
00050 public:
00051   virtual ~csImageBase() { delete[] fName; }
00052 
00053   /* Commented out: should be implemented by all descendants.
00054   virtual const void *GetImageData () { return 0; }
00055   virtual int GetWidth () const { return 0; }
00056   virtual int GetHeight () const { return 0; }
00057   */
00058   // Most images are 2D, so provide a sensible default
00059   virtual int GetDepth () const { return 1; }
00060 
00061   virtual void SetName (const char *iName)
00062   {
00063     delete[] fName; fName = csStrNew (iName);
00064   }
00065   virtual const char *GetName () const { return fName; }
00066 
00067   /* Commented out: should be implemented by all descendants.
00068   virtual int GetFormat () const { return 0; }
00069   */
00070   virtual const csRGBpixel* GetPalette () { return 0; }
00071   virtual const uint8* GetAlpha () { return 0; }
00072 
00073   virtual bool HasKeyColor () const { return false; }
00074   CS_DEPRECATED_METHOD virtual bool HasKeycolor () const
00075   { return HasKeyColor(); }
00076 
00077   virtual void GetKeyColor (int & /*r*/, int & /*g*/, int & /*b*/) const { }
00078   CS_DEPRECATED_METHOD virtual void GetKeycolor (int &r, int &g, int &b) const
00079   { GetKeyColor (r, g, b); }
00080 
00081   virtual uint HasMipmaps () const { return 0; }
00082   virtual csRef<iImage> GetMipmap (uint num) 
00083   { return (num == 0) ? this : 0; }
00084 
00085   virtual const char* GetRawFormat() const { return 0; }
00086   virtual csRef<iDataBuffer> GetRawData() const { return 0; }
00087   virtual csImageType GetImageType() const { return csimg2D; }
00088   virtual uint HasSubImages() const { return 0; }
00089   virtual csRef<iImage> GetSubImage (uint num) 
00090   { return (num == 0) ? this : 0; }
00091 };
00092 
00095 #endif // __CS_CSGFX_IMAGEBASE_H__

Generated for Crystal Space by doxygen 1.4.4