1 //------------------------------------------------------------------------------ 2 // emTgaImageFileModel.h 3 // 4 // Copyright (C) 2004-2008,2014,2018 Oliver Hamann. 5 // 6 // Homepage: http://eaglemode.sourceforge.net/ 7 // 8 // This program is free software: you can redistribute it and/or modify it under 9 // the terms of the GNU General Public License version 3 as published by the 10 // Free Software Foundation. 11 // 12 // This program is distributed in the hope that it will be useful, but WITHOUT 13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 // FOR A PARTICULAR PURPOSE. See the GNU General Public License version 3 for 15 // more details. 16 // 17 // You should have received a copy of the GNU General Public License version 3 18 // along with this program. If not, see <http://www.gnu.org/licenses/>. 19 //------------------------------------------------------------------------------ 20 21 #ifndef emTgaImageFileModel_h 22 #define emTgaImageFileModel_h 23 24 #ifndef emImageFile_h 25 #include <emCore/emImageFile.h> 26 #endif 27 28 29 class emTgaImageFileModel : public emImageFileModel { 30 31 public: 32 33 static emRef<emTgaImageFileModel> Acquire( 34 emContext & context, const emString & name, bool common=true 35 ); 36 37 protected: 38 39 emTgaImageFileModel(emContext & context, const emString & name); 40 virtual ~emTgaImageFileModel(); 41 virtual void TryStartLoading(); 42 virtual bool TryContinueLoading(); 43 virtual void QuitLoading(); 44 virtual void TryStartSaving(); 45 virtual bool TryContinueSaving(); 46 virtual void QuitSaving(); 47 virtual emUInt64 CalcMemoryNeed(); 48 virtual double CalcFileProgress(); 49 50 private: 51 52 int Read8(); 53 int Read16(); 54 55 struct LoadingState { 56 FILE * File; 57 emColor * Palette; 58 emColor RunCol; 59 int IDLen,CMapType,IMapType,CMapSize,CMapBitsPP; 60 int Width,Height,BitsPP,Descriptor,ChannelCount; 61 int NextY,RunLen; 62 bool ImagePrepared; 63 }; 64 65 LoadingState * L; 66 }; 67 68 69 #endif 70