Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages
commonimagefile.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2005 by Jorrit Tyberghein 00003 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 00020 #ifndef __CS_CSPLUGINCOMMON_IMAGELOADER_COMMONIMAGEFILE_H__ 00021 #define __CS_CSPLUGINCOMMON_IMAGELOADER_COMMONIMAGEFILE_H__ 00022 00027 #include "csextern.h" 00028 #include "iutil/databuff.h" 00029 #include "iutil/job.h" 00030 #include "csutil/ref.h" 00031 #include "csgfx/memimage.h" 00032 00041 enum csLoaderDataType 00042 { 00044 rdtInvalid, 00046 rdtR8G8B8, 00048 rdtRGBpixel, 00050 rdtIndexed 00051 }; 00052 00053 class csCommonImageFile; 00054 00055 SCF_VERSION (iImageFileLoader, 0, 0, 1); 00056 00061 struct iImageFileLoader : public iBase 00062 { 00064 virtual bool LoadData () = 0; 00066 virtual csRef<iDataBuffer> GetRawData() = 0; 00068 virtual csLoaderDataType GetDataType() = 0; 00070 virtual int GetWidth() = 0; 00072 virtual int GetHeight() = 0; 00074 virtual int GetFormat() = 0; 00076 virtual void ApplyTo (csImageMemory* image) = 0; 00077 }; 00078 00082 class CS_CSPLUGINCOMMON_EXPORT csCommonImageFileLoader : public iImageFileLoader 00083 { 00084 protected: 00085 int Format; 00086 csRef<iDataBuffer> rawData; 00087 csLoaderDataType dataType; 00088 csRGBpixel* rgbaData; 00089 uint8* indexData; 00090 csRGBpixel* palette; 00091 size_t paletteCount; 00092 uint8* alpha; 00093 bool hasKeycolor; 00094 csRGBcolor keycolor; 00095 int Width, Height; 00096 public: 00097 SCF_DECLARE_IBASE; 00098 00099 csCommonImageFileLoader (int format); 00100 virtual ~csCommonImageFileLoader(); 00101 00102 virtual csRef<iDataBuffer> GetRawData() 00103 { return rawData; } 00104 virtual csLoaderDataType GetDataType() 00105 { return dataType; } 00106 virtual int GetWidth() { return Width; } 00107 virtual int GetHeight() { return Height; } 00108 virtual int GetFormat() { return Format; } 00109 virtual void ApplyTo (csImageMemory* image); 00110 }; 00111 00112 #define THREADED_LOADING 00113 00117 class CS_CSPLUGINCOMMON_EXPORT csCommonImageFile : public csImageMemory 00118 { 00119 protected: 00120 friend class csCommonImageFileLoader; 00121 00122 class CS_CSPLUGINCOMMON_EXPORT LoaderJob : public iJob 00123 { 00124 public: 00125 csRef<iImageFileLoader> currentLoader; 00126 bool loadResult; 00127 SCF_DECLARE_IBASE; 00128 00129 LoaderJob (iImageFileLoader* loader); 00130 virtual ~LoaderJob(); 00131 00132 virtual void Run(); 00133 }; 00134 00135 #ifdef THREADED_LOADING 00136 csRef<LoaderJob> loadJob; 00137 csRef<iJobQueue> jobQueue; 00138 #else 00139 csRef<iImageFileLoader> currentLoader; 00140 #endif 00141 iObjectRegistry* object_reg; 00142 00143 csCommonImageFile (iObjectRegistry* object_reg, int format); 00144 virtual ~csCommonImageFile(); 00145 00147 virtual bool Load (csRef<iDataBuffer> source); 00153 virtual csRef<iImageFileLoader> InitLoader (csRef<iDataBuffer> source) = 0; 00154 00156 void WaitForJob() const; 00158 void MakeImageData(); 00159 00160 virtual const void *GetImageData (); 00161 virtual const csRGBpixel* GetPalette (); 00162 virtual const uint8* GetAlpha (); 00163 00164 static const char* DataTypeString (csLoaderDataType dataType); 00165 virtual const char* GetRawFormat() const; 00166 virtual csRef<iDataBuffer> GetRawData() const; 00167 }; 00168 00171 #endif // __CS_CSPLUGINCOMMON_IMAGELOADER_COMMONIMAGEFILE_H__
Generated for Crystal Space by doxygen 1.3.9.1