CrystalSpace

Public API Reference

csgfx/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 #include "csutil/scf_implementation.h"
00035 
00036 #include "igraphic/image.h"
00037 
00038 
00042 class csImageBase :
00043   public scfImplementation1<csImageBase, iImage>
00044 {
00045 protected:
00047   char* fName;
00049   csImageBase() :
00050     scfImplementationType(this, 0), fName(0)
00051   { }
00052 public:
00053   virtual ~csImageBase() { delete[] fName; }
00054 
00055   /* Commented out: should be implemented by all descendants.
00056   virtual const void *GetImageData () { return 0; }
00057   virtual int GetWidth () const { return 0; }
00058   virtual int GetHeight () const { return 0; }
00059   */
00060   // Most images are 2D, so provide a sensible default
00061   virtual int GetDepth () const { return 1; }
00062 
00063   virtual void SetName (const char *iName)
00064   {
00065     delete[] fName; fName = csStrNew (iName);
00066   }
00067   virtual const char *GetName () const { return fName; }
00068 
00069   /* Commented out: should be implemented by all descendants.
00070   virtual int GetFormat () const { return 0; }
00071   */
00072   virtual const csRGBpixel* GetPalette () { return 0; }
00073   virtual const uint8* GetAlpha () { return 0; }
00074 
00075   virtual bool HasKeyColor () const { return false; }
00076   CS_DEPRECATED_METHOD virtual bool HasKeycolor () const
00077   { return HasKeyColor(); }
00078 
00079   virtual void GetKeyColor (int & /*r*/, int & /*g*/, int & /*b*/) const { }
00080   CS_DEPRECATED_METHOD virtual void GetKeycolor (int &r, int &g, int &b) const
00081   { GetKeyColor (r, g, b); }
00082 
00083   virtual uint HasMipmaps () const { return 0; }
00084   virtual csRef<iImage> GetMipmap (uint num) 
00085   { return (num == 0) ? this : 0; }
00086 
00087   virtual const char* GetRawFormat() const { return 0; }
00088   virtual csRef<iDataBuffer> GetRawData() const { return 0; }
00089   virtual csImageType GetImageType() const { return csimg2D; }
00090   virtual uint HasSubImages() const { return 0; }
00091   virtual csRef<iImage> GetSubImage (uint num) 
00092   { return (num == 0) ? this : 0; }
00093 };
00094 
00097 #endif // __CS_CSGFX_IMAGEBASE_H__

Generated for Crystal Space by doxygen 1.4.6