- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我试图将图像的字节数组放入外部 eeprom (c24LC16B) 并使用 Adafruit gfx 库中的 drawBitmap() 函数在 Nokia 3310 LCD(带有 Adafruit PCD8544 库)上绘制它。但问题是,drawBitmap() 只能使用静态字节 PROGMEM 数组。使用不好,我需要从 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);
}
}
}
但它仍然只显示垃圾
那么为什么 PROGMEM 和普通数组有这么大的区别呢?来自 PROGMEM 和来自 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++ - 没有 PROGMEM 的 Adafruit gfx 库 drawBitmap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32417848/
我正在使用dojo.gfx在我的网站上创建矢量形状和文本,当我“dojo.require”-ing我的Javascript中的所有依赖项时,一切正常。但是,当我在自定义构建中构建所需的所有内容时(尤其
在使用 dojo 的 gfx 渲染文本时,有没有办法告诉文本将占用多少空间,以防我需要包装它以使其适合给定的宽度? 如果您必须使它们适合宽度受限的区域,您将如何管理打印任意长度的文本? 更新 :对不起
我正在使用 adb shell dumpsys meminfo 来获取有关我的应用程序当前内存使用情况的信息。Gfx dev 内存增加频繁,似乎导致内存泄漏。 是否有 adb 命令或 Android
我正在关注 a tutorial on the gfx library .以下代码用于初始化窗口系统,它使用隐式类型绑定(bind)返回各种位。 let (window, mut device, mu
本文整理了Java中com.github.gfx.ribbonizer.YellowRibbonBuilder类的一些代码示例,展示了YellowRibbonBuilder类的具体用法。这些代码示例主
我发现接受索引缓冲区的唯一方法是: let (vbuf, slice) = factory.create_vertex_buffer(&verts, &indices); 这会创建一个新缓冲区,我不能
dojo 中 getBoundingBox() 的文档说: Returns a bounding box of a shape. A text shape is a point-based objec
我正在使用以下 html 从 Google 的托管加载 dojo。 google.load("dojo", "1.1.1"); dojo.require("dojox.gfx"); ... 这个错
有如下代码。期望的结果是创建一个窗口并绘制一个实心圆: #include #include #include int main() { SDL_Window* window = nullp
我正在使用 Dojo 的 gfx 例程在 div 上绘制一些形状,除了 surface.clear() 之外,是否有办法清除或删除表面的一部分? 最佳答案 简而言之:没有。请记住,这是带有场景图的矢量
我正在尝试绘制到屏幕外渲染目标 type ColorFormat = gfx::format::Rgba8; gfx_defines! { pipeline terrain {
如果用户不支持我为更快地渲染某些内容而制作的着色器,我需要进行回退。 那么,我究竟该如何检查这些东西呢?我知道某些 GLSL 版本不支持某些着色器函数,但是,这些函数与所需版本的完整列表在哪里? 但问
我将为浏览器应用程序构建一个简单的数学图表。因此,所有 JS-Vector 库都可能运行良好。但我想知道您使用这些工具收集到的任何经验。对我来说,一个基本功能是将事件绑定(bind)到路径和点以及动画
我正在寻找某种适用于 Android 的 2D 图形引擎。在我的特殊情况下,我只想移动一些 Sprites,播放简短的声音,或许还可以播放一些简单的动画。 我知道,我可以自己做所有这些事情,但出于个人
我正在尝试将 gfx 模块用于 python(来自此处:http://www.swftools.org/gfx_tutorial.html)。但是当我执行 python setup.py build
我正在使用 Dojo GFX 进行一些简单的绘图,但在使用 IE 7/8 时遇到问题(无法切换浏览器)。 如果我创建一个 div,设置一个表面并绘制一些矩形,它们相对于 div 正确绘制,到目前为止一
dojox.gfx (GFX) 是一个与 dojo 一起运行的跨平台矢量图形 API。 它有助于将您的应用程序与所有现代浏览器中的许多 native 矢量图形实现差异隔离开来。 来自dojox/gfx
Resonantly 我必须使用 .gfx 文件,但我没有太多关于 gfx 文件的信息。我的问题是: .gfx 文件格式的文件包含什么? 是任何类型的图像文件或视频文件。 从哪里可以获得 .gfx 示
我打算使用 D3 或 Dojo GFX 中的一种来创建一些大数据视觉效果,例如 TreeMap、Wave-forms 等。D3 的优点在于,其中许多可视化效果已经可以作为示例实现使用,以实现快速开发。
本文整理了Java中com.github.gfx.ribbonizer.YellowRibbonBuilder.()方法的一些代码示例,展示了YellowRibbonBuilder.()的具体用法。这
我是一名优秀的程序员,十分优秀!