QImage中的bytesPerLine是什么意思?

4

bytesPerLine 在 IT 技术中的含义是什么?

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

文档中提到bytesPerLine指定每行的字节数(步幅)。
我不清楚它的用法。width和bytesPerLine是相同的吗?请问有人能解释一下吗?

1个回答

9

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);

8位灰度图像的每个像素占用1个字节吗? - indira

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接