0
我想解析Arduino上的XBM位图,根本没有运气(期望< 16x16位图)。经过大量的搜索,研究和修补,我已经达到了这个功能。我确定我正确地阅读了字节(测试),但转换有问题。在Arduino上绘制XBM位图
void bitmap(int x, int y, uint16_t *bitmap, uint8_t w, uint8_t h) {
uint16_t dots, msb;
uint16_t col, row;
msb = 1 << (w - 1);
for (row = 0; row < h; row++) {
dots = pgm_read_word(bitmap + row);
//Serial.print(dots, HEX);
//Serial.println(" ");
for (col = 0; col < w; col++) {
if (dots & (msb >> col))
Serial.print("#"); //toolbox.setPixel(x, y, 1, false);
else
Serial.print("'"); //toolbox.setPixel(x, y, 0, false);
}
Serial.println("");
}
}
这是我试图展示的位图。它的大小为32x32像素。 16x16或更少的图像显示正确。
// 32x32
uint16_t medium[] PROGMEM = {
0xffff, 0xffff, 0x0000, 0x8000, 0xffff, 0xffff, 0x0001, 0x0000, 0xffff,
0xffff, 0x0000, 0x8000, 0xffff, 0xffff, 0x0001, 0x0000, 0xffff, 0xffff,
0x0000, 0x8000, 0xffff, 0xffff, 0x0001, 0x0000, 0xffff, 0xffff, 0x0000,
0x8000, 0xffff, 0xffff, 0x0001, 0x0000, 0xffff, 0xffff, 0x0000, 0x8000,
0xffff, 0xffff, 0x0001, 0x0000, 0xffff, 0xffff, 0x0000, 0x8000, 0xffff,
0xffff, 0x0001, 0x0000, 0xffff, 0xffff, 0x0000, 0x8000, 0xffff, 0xffff,
0x0001, 0x0000, 0xffff, 0xffff, 0x0000, 0x8000, 0xffff, 0xffff, 0x0001,
0x0000 };
这是位图的PNG供参考:响应于评价: