- Code: Select all
// Draw inverted-color bitmap from SRAM char array
void drawBitmapA(byte x, byte y, char *bitmap, uint16_t color) { // where bitmap[] is the char array containing bitmap data
byte w = bitmap[0];
byte h = bitmap[1];
byte 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, color);
}
}
}
}
// Draw inverted-color bitmaps from SRAM for use with tilemap duhjoker
void drawBitmapB(byte x, byte y, char *bitmap, uint8_t dx, uint8_t dy, uint8_t dw, uint8_t dh, uint16_t color) { // where bitmap[] is the char array containing bitmap data
byte w = bitmap[0];
byte h = bitmap[1];
byte i, j, byteNum, bitNum, byteWidth = (w + 7) >> 3;
dw += dx;
dh += dy;
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))) {
int8_t drawX = x + i;
int8_t drawY = y + j;
if (drawX >= dx && drawX < dw && drawY >= dy && drawY < dh) {
drawPixel(x, y, color);
}
}
}
}
}
// Draw bitmap from SD at position x0, y0
int drawBitmapFromSd(byte x0, byte y0, char *bitmap, uint16_t color) { // where bitmap[] is the name of the bitmap file on SD
char buf[13]; // max 2 bytes for W/H + 11 bytes of data to cover the 84 pixel width of the Gamebuino screen
// 1. open bitmap file
// open real bitmap on SD
(pf_open(bitmap)); return BMP_NO_FILE;
// 2a. read information from bitmap header > identifier
readNCharsAt(2, 0, buf); // BMP.wIdentifier
buf[2] = NULL;
if (strcmp(buf, "BM")) return BMP_NOT_WBM;
// 2b. read information from bitmap header > bpp, compression and data size
readNCharsAt(10, 28, buf); // BMP.wBitsPerPixel + BMP.dwCompression + BMP.dwDataSize
if (WORD(buf, 0) != 1) return BMP_NOT_1BPP; // not a 1bpp bitmap
if (LONG(buf, 2)) return BMP_ERR_CMP; // not an UNcompressed bitmap
word datasize = WORD(buf, 6);
// 2c. read information from bitmap header > data offset
readNCharsAt(4, 10, buf); // BMP.dwDataOffset
word offset = WORD(buf, 0);
// 2d. read information from bitmap header > dimensions
readNCharsAt(8, 18, buf); // BMP.dwWidth + BMP.dwHeight
byte w = (byte)buf[0];
if (w>LCDWIDTH) return BMP_TOO_BIG;
byte h = (byte)buf[4];
byte datalen = datasize / h;
// 3. read and draw bitmap data
buf[0] = w; buf[1] = 1; // get bitmap data line by line
for (byte y = 0; y<h; y++) {
readNCharsAt(datalen, offset + y*datalen, buf + 2);
drawBitmapA(x0, y0 + (h - 1) - y, buf, color); // and draw it!
}
return BMP_OK;
}
ive tried all kinds of stuff like adding or removing brackets but I cannot get the code to declare the drawpixel in the scope.
- Code: Select all
Arduino: 1.6.11 (Windows 7), TD: 1.30-beta3, Board: "Teensy 3.2 / 3.1, Serial, 72 MHz optimize speed, US English"
C:\Users\duhjoker\Documents\Arduino\libraries\gamebuinoAPcolorSD\DisplayRGB.cpp: In member function 'void Display::drawBitmap(int8_t, int8_t, int8_t, int8_t, const uint8_t*, uint8_t, uint8_t, uint8_t, uint8_t, uint16_t)':
C:\Users\duhjoker\Documents\Arduino\libraries\gamebuinoAPcolorSD\DisplayRGB.cpp:709:9: warning: unused variable 'largest' [-Wunused-variable]
int8_t largest = 0;
^
C:\Users\duhjoker\Documents\Arduino\libraries\gamebuinoAPcolorSD\DisplayRGB.cpp:710:9: warning: unused variable 'largesty' [-Wunused-variable]
int8_t largesty = 0;
^
C:\Users\duhjoker\Documents\Arduino\libraries\gamebuinoAPcolorSD\DisplayRGB.cpp: In function 'void drawBitmapA(byte, byte, char*, uint16_t)':
C:\Users\duhjoker\Documents\Arduino\libraries\gamebuinoAPcolorSD\DisplayRGB.cpp:734:34: error: 'drawPixel' was not declared in this scope
drawPixel(x + i, y + j, color);
^
C:\Users\duhjoker\Documents\Arduino\libraries\gamebuinoAPcolorSD\DisplayRGB.cpp: In function 'void drawBitmapB(byte, byte, char*, uint8_t, uint8_t, uint8_t, uint8_t, uint16_t)':
C:\Users\duhjoker\Documents\Arduino\libraries\gamebuinoAPcolorSD\DisplayRGB.cpp:755:27: error: 'drawPixel' was not declared in this scope
drawPixel(x, y, color);
^
C:\Users\duhjoker\Documents\Arduino\libraries\gamebuinoAPcolorSD\DisplayRGB.cpp: In function 'int drawBitmapFromSd(byte, byte, char*, uint16_t)':
C:\Users\duhjoker\Documents\Arduino\libraries\gamebuinoAPcolorSD\DisplayRGB.cpp:770:9: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null]
buf[2] = NULL;
^
Error compiling for board Teensy 3.2 / 3.1.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
can someone show how to fix these please?!!!