qt - QImage 中的 bytesPerLine 是什么意思?

标签 qt qt4

bytesPerLine in 是什么意思

QImage::QImage ( uchar * data, int width, int height, int bytesPerLine, Format format )

在文档中,它被称为 bytesPerLine 指定每行的字节数(步幅)。
我不清楚它的用法。 width 和 bytesPerLine 是否相同?有人可以解释一下吗?

最佳答案

bytesperline 表示给定行中图像像素所需的字节数。

为了说明这一点,请考虑以下代码片段...

int imageWidth = 800;
int imageHeight = 600;
int bytesPerPixel = 4; // 4 for RGBA, 3 for RGB
int format = QImage::Format_ARGB32; // this is the pixel format - check Qimage::Format enum type for more options
QImage image(yourData, imageWidth, imageHeight, imageWidth * bytesPerPixel, format);

关于qt - QImage 中的 bytesPerLine 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9513227/

相关文章:

qt - 奇怪的 QTableWidget 行为 - 排序后并非所有单元格都填充,然后重新填充

c++ - Qt QGraphicsScene 添加和删除线条

c++ - 如何自动将qwidget保存为图像

c++ - 为单选按钮创建组

Python/PyQT : How can I truncate a text in QLineEdit

c++ - QT 创建者和 Qt(只是它本身)的区别 - 启动 QT

c++ - 处理重叠图形项的 mousePressEvent

c++ - Qt WEBKIT 与 CMake

c++ - QListView默认选择模型的所有权

python - 删除所有 DockWidgets 后如何调整 QMainWindow 的大小?