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