Serial.begin(9600); PFFS.begin(10, rx, tx); // initialize petit_fatfs
pf_open("test.bmp");
char bmp[13]; // 1 byte for width + 1 byte for height + 11 bytes for 1 line of bitmap data (84/8 rounded-up)
gb.display.persistence=true; // stop clearing screen at every gb.update()
gb.display.clear();
bmp[0]=84; bmp[1]=1; // get bitmap data line by line i.e. bmp dimension is 84x1
WORD br;
for(byte y=0; y<48; y++) {
pf_lseek(y*11);
pf_read((void*)&bmp[2], 11, &br);
gb.display.drawBitmap(0, y, bmp); // and draw it!
}
void drawBitmap(int8_t x, int8_t y, char *bitmap);
void Display::drawBitmap(int8_t x, int8_t y, char *bitmap) {
byte w = bitmap[0];
byte h = bitmap[1];
#if (ENABLE_BITMAPS > 0)
int8_t i, j, byteNum, bitNum, byteWidth = (w + 7) >> 3;
for (i = 0; i < w; i++) {
byteNum = i / 8;
bitNum = i % 8;
for (j = 0; j < h; j++) {
if ((bitmap[2 + j * byteWidth + byteNum]) & (B10000000 >> bitNum)) {
drawPixel(x + i, y + j);
}
}
}
#else
drawRect(x, y, w, h);
#endif
}
Return to Software Development
Users browsing this forum: No registered users and 112 guests