1 /* GemRB - Infinity Engine Emulator 2 * Copyright (C) 2003 The GemRB Project 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 * 18 * 19 */ 20 21 #ifndef BAMIMPORTER_H 22 #define BAMIMPORTER_H 23 24 #include "AnimationMgr.h" 25 26 #include "RGBAColor.h" 27 #include "globals.h" 28 #include "Holder.h" 29 30 namespace GemRB { 31 32 struct FrameEntry { 33 ieWord Width; 34 ieWord Height; 35 ieWord XPos; 36 ieWord YPos; 37 ieDword FrameData; 38 }; 39 40 class Palette; 41 using PaletteHolder = Holder<Palette>; 42 43 class BAMImporter : public AnimationMgr { 44 private: 45 DataStream* str; 46 FrameEntry* frames; 47 CycleEntry* cycles; 48 ieWord FramesCount; 49 ieByte CyclesCount; 50 PaletteHolder palette; 51 ieByte CompressedColorIndex; 52 ieDword FramesOffset, PaletteOffset, FLTOffset; 53 unsigned long DataStart; 54 private: 55 Holder<Sprite2D> GetFrameInternal(unsigned short findex, unsigned char mode, 56 bool RLESprite, unsigned char* data); 57 void* GetFramePixels(unsigned short findex); 58 ieWord * CacheFLT(unsigned int &count); 59 public: 60 BAMImporter(void); 61 ~BAMImporter(void) override; 62 bool Open(DataStream* stream) override; 63 int GetCycleSize(unsigned char Cycle) override; 64 AnimationFactory* GetAnimationFactory(const char* ResRef, 65 unsigned char mode = IE_NORMAL, bool allowCompression = true) override; 66 /** Debug Function: Returns the Global Animation Palette as a Sprite2D Object. 67 If the Global Animation Palette is NULL, returns NULL. */ 68 Holder<Sprite2D> GetPalette() override; 69 70 /** Gets a Pixel Index from the Image, unused */ GetPixelIndex(unsigned int,unsigned int)71 unsigned int GetPixelIndex(unsigned int /*x*/, unsigned int /*y*/) 72 { 73 return 0; 74 } 75 /** Gets a Pixel from the Image, unused */ GetPixel(unsigned int,unsigned int)76 Color GetPixel(unsigned int /*x*/, unsigned int /*y*/) 77 { 78 return Color(); 79 } 80 public: GetCycleCount()81 int GetCycleCount() override 82 { 83 return CyclesCount; 84 } 85 }; 86 87 } 88 89 #endif 90