Adafruit gfx库绘制位图没有程序
Adafruit gfx library drawBitmap without PROGMEM
所以我试图把字节数组的图像在外部eeprom (c24LC16B)和使用drawBitmap()函数在Adafruit gfx库绘制它在诺基亚3310 LCD(与Adafruit PCD8544库)。但问题是,drawBitmap()只能使用静态字节程序数组。我需要从eeprom读取img数组到缓冲区(字节buf[504]{};)然后把它画出来展示。
我尝试了一些修改,我在网上找到的,比如把这个添加到Adafruit_GFX.ccp:
void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
uint8_t *bitmap, int16_t w, int16_t h,
uint16_t color) {
int16_t i, j, byteWidth = (w + 7) / 8;
for(j=0; j<h; j++) {
for(i=0; i<w; i++ ) {
if(bitRead(bitmap[j], 7-i))
drawPixel(x+i, y+j, color);
}
}
}
但它仍然只显示垃圾
那么为什么程序和普通数组有这么大的区别呢?字节从程序和从SRAM是一样的吗?也为我的语法感到抱歉
我做到了!我所要做的就是写我自己的函数!= D
请将此添加到Adafruit_GFX.ccp
void Adafruit_GFX::drawRamBitmap(int pozXi, int pozYi, int h, int w, byte color, byte bg, byte bitmap[], int mapSize) {
int pozX = pozXi;
int pozY = pozYi;
for (int x = 0; x < mapSize; x++) {
for (byte y = 0; y < 8; y++) {
byte dummy = bitmap[x] << y;
if (dummy >= 128) {
drawPixel(pozX, pozY, color);
}
else {
drawPixel(pozX, pozY, bg);
}
pozX++;
if (pozX == w + pozXi) {
pozX = pozXi;
pozY++;
}
}
}
}
void Adafruit_GFX::drawRamBitmap(int pozXi, int pozYi, int h, int w, byte color, byte bitmap[], int mapSize) {
int pozX = pozXi;
int pozY = pozYi;
for (int x = 0; x < mapSize; x++) {
for (byte y = 0; y < 8; y++) {
byte dummy = bitmap[x] << y;
if (dummy >= 128) {
drawPixel(pozX, pozY, color);
}
pozX++;
if (pozX == w + pozXi) {
pozX = pozXi;
pozY++;
}
}
}
}
和Adafruit_GFX.h
drawRamBitmap(int pozXi, int pozYi, int h, int w, byte color, byte bg, byte bitmap[], int mapSize),
drawRamBitmap(int pozXi, int pozYi, int h, int w, byte color, byte bitmap[], int mapSize),
用法:
drawRambitmap(x,y,h,w,color,byte_array_of_img, size_of_array);
或
drawRambitmap(x,y,h,w,color,background_color,byte_array_of_img, size_of_array);
相关文章:
- C / C++ 移位/偏移/向左或向右移动位图?
- 如何在快板的屏幕中显示子位图的绘制?
- CreateDIBSection为同一图像返回不一致的位图位值
- C++ 位图中的 ttc 字体
- 使用 GDI+ 旋转位图,然后转换为 HDC
- 难以从 CImageList 设置菜单项位图
- 如何将位图拉伸到父面板(wxWidgets 自定义)
- 如何使用 freetype2 访问单色位图中的像素状态
- 将位图 (bmp) 转换为具有透明度的 png (Windows c++)
- 安卓工作室 |CPP 文件错误错误: 位图库中对"AndroidBitmap_unlockPixels"的未定义引用
- 位图到垫子/2D 数组
- Gdiplus位图没有Alpha通道
- 如何从路径字符串加载Gdiplus::位图
- 在C++中使用Gdiplus创建透明位图
- 用C++压缩内存中的位图
- 来自程序子窗口的位图返回为黑色
- 当程序最小化时位图消失
- OpenGL位图程序只显示白色,黑色和黄色
- Adafruit gfx库绘制位图没有程序
- Opencv/C++-将NV21转换为RGB并在android应用程序中生成位图