QImage与Format_Mono如何存储信息
How does QImage with Format_Mono store informations ?
我试图从QImage复制值到我自己的图像结构(因为学校的工作),我无法弄清楚,像素是如何存储的
API说,当使用Format_Mono时,图像以每像素1位存储。
我创建了以下代码:QImage image(10,10,QImage::Format_Mono); // create 10x10 image
image.fill(1); // whiten the image
QPainter p;
p.begin(&image);
p.setPen(QPen(QColor(Qt::black)));
p.drawPoint(10,1); // make ONE point black
p.end();
uchar* pixels = image.constBits();
int count = image.byteCount(); // returns 40 !!
第一件事:我不明白为什么使用40个字节(我预计20个就足够了-就像java中的BufferedImage
一样)
第二件事:当迭代像素时,每四个字节(从第三个索引2,6,10…开始)设置为173,每四个字节(从第四个索引3,7,11…开始)设置为186。其他字节被正确地(??)设置为255(白色)。
我期望20个字节,因此19将被设置为255,而1(将彩色像素[10,1]设置为其他值)
我错过了什么?谢谢你
API:扫描线数据在32位边界上对齐。
那就是……的原因。方法bits()的Qt文档忘记提到了…
相关文章:
- 将数组信息存储到 c++ 向量中有一个"Access violation reading location"
- 按字母顺序打印存储在字符数组中的信息
- 如何修复函数中的 fstream 文件输入以将正确的信息存储在结构数组中?
- 对于存储另一个类所需信息的类,例如其构造,是否有设计模式?
- structtm是否将时区信息存储为其数据成员
- 将不同的模板化类存储在一个容器中,而不会丢失有关其类型的信息
- 合法的方式将destructor信息存储到void*
- 为什么类型转换对象不会更改其地址?有关对象类型的信息存储在哪里?
- 为什么C++不使用集中存储类型信息以实现高效的 RTTI
- (C++) 如何从要存储在结构数组中的二进制文件中读取.dat信息?
- 我应该如何存储从文件中获取的这些信息?
- 在TXT文档的一部分中查找信息并将其存储在变量中
- 如何将循环中的信息存储到数组中
- 信息实际上并未存储在节点阵列中
- DAWG可以用于存储与单词相关的信息吗?
- 获取存储在矢量结构中的信息时出现问题
- 如何在派生类中存储基类初始化期间获得的信息
- 使用 fstream 对象将文件中的信息存储到变量中
- 在 Windows 上存储信息有哪些选项?我应该如何阅读此信息
- QImage与Format_Mono如何存储信息