diff --git a/src/Arduboy2.cpp b/src/Arduboy2.cpp index 4d094bc..1093558 100644 --- a/src/Arduboy2.cpp +++ b/src/Arduboy2.cpp @@ -856,17 +856,18 @@ void Arduboy2Base::drawSlowXYBitmap } } - // Helper for drawCompressed() -struct Arduboy2Base::BitStreamReader +class Arduboy2Base::BitStreamReader { + private: const uint8_t *source; uint16_t sourceIndex; uint8_t bitBuffer; uint8_t byteBuffer; - BitStreamReader(const uint8_t *source) - : source(source), sourceIndex(), bitBuffer(), byteBuffer() + public: + BitStreamReader(const uint8_t *bitmap) + : source(bitmap), sourceIndex(), bitBuffer(), byteBuffer() { } @@ -875,17 +876,17 @@ struct Arduboy2Base::BitStreamReader uint16_t result = 0; for (uint16_t i = 0; i < bitCount; i++) { - if (this->bitBuffer == 0) + if (bitBuffer == 0) { - this->bitBuffer = 0x1; - this->byteBuffer = pgm_read_byte(&this->source[this->sourceIndex]); - ++this->sourceIndex; + bitBuffer = 0x1; + byteBuffer = pgm_read_byte(&source[sourceIndex]); + ++sourceIndex; } - if ((this->byteBuffer & this->bitBuffer) != 0) + if ((byteBuffer & bitBuffer) != 0) result |= (1 << i); - this->bitBuffer <<= 1; + bitBuffer <<= 1; } return result; } @@ -894,7 +895,7 @@ struct Arduboy2Base::BitStreamReader void Arduboy2Base::drawCompressed(int16_t sx, int16_t sy, const uint8_t *bitmap, uint8_t color) { // set up decompress state - BitStreamReader cs = BitStreamReader(bitmap); + BitStreamReader cs(bitmap); // read header int width = (int)cs.readBits(8) + 1; diff --git a/src/Arduboy2.h b/src/Arduboy2.h index 7403355..14b228e 100644 --- a/src/Arduboy2.h +++ b/src/Arduboy2.h @@ -1376,7 +1376,7 @@ class Arduboy2Base : public Arduboy2Core uint8_t sides, int16_t delta, uint8_t color = WHITE); // helper for drawCompressed() - struct BitStreamReader; + class BitStreamReader; // swap the values of two int16_t variables passed by reference void swapInt16(int16_t& a, int16_t& b);