G.U.L.L.S/include/GIFMatrix.h

89 lines
2.2 KiB
C++

#ifndef GIFMATRIX_H
#define GIFMATRIX_H
#include "SD.h"
#include "MatrixAnimation.h"
class GIFMatrix : public MatrixAnimation {
public:
GIFMatrix(LEDHAL2D* _matrix, char* _refName, long _updateTime, File* _dataFile) :
MatrixAnimation(_matrix, _refName, _updateTime), dataFile(_dataFile) {
STANDARDHEADER[0] = 0x47;
STANDARDHEADER[1] = 0x49;
STANDARDHEADER[2] = 0x46;
STANDARDHEADER[3] = 0x38;
STANDARDHEADER[4] = 0x39;
STANDARDHEADER[5] = 0x61;
if(!headerOK()) {
// I can't throw exceptions, need to do something here...
}
decodeLogicalDescriptor();
preImageDataBytes = 6 + 7 + (globalColorTableExists ? globalColorTableSize * 3 : 0);
lastCode = _dataFile->read();
}
void initialize() {
// Reinitialization needs to be tested, this may not work correctly
dataFile->seek(preImageDataBytes);
resetTimer();
}
void execute();
bool headerOK();
void decodeLogicalDescriptor();
void decodeGlobalColorTable();
void decodeGraphicControlExtension();
void decodeApplicationExtension();
void decodeImageDescriptor();
void buildCodeTable();
void drawForArray(CRGB* colorTable, uint16_t* indexes, uint16_t startingXPosition, uint16_t imageWidth);
uint16_t readWord();
private:
File*
dataFile;
uint16_t
preImageDataBytes,
currentXPosition,
currentYPosition,
gifCanvasWidth,
gitCanvasHeight,
currentImageLeft,
currentImageTop,
currentImageWidth,
currentImageHeight,
currentCCCode,
currentEOICode;
uint16_t**
currentCodeTable;
long
delayTime;
uint8_t
lastCode,
originalColorResolution,
globalColorTableSize,
globalColorTableBackgroundColorIndex,
disposalMethodValue,
userInputFlag,
transparentColorFlag,
transparentColorIndex,
localColorTableSize,
currentMinimumCodeSize;
bool
globalColorTableExists,
globalColorTableSorted,
localColorTableExists,
interlaceFlag,
localColorTableSorted;
CRGB*
globalColorTable,
localColorTable;
byte
STANDARDHEADER[6];
};
#endif