2012-03-01 992 views
1

什麼是通過平均在bytesPerLineQImage中的bytesPerLine是什麼意思?

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

在它被提及作爲bytesPerLine文檔指定每行(步幅)的字節數。
我不清楚它的用法。寬度和bytesPerLine是否相同?任何人都可以解釋一下嗎?

回答

5

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

這是ü將如何使用上述構造.. – shofee 2012-03-01 09:17:17

+0

沒有它的工作.... – shofee 2012-03-01 09:22:22

+0

bytesPerPixel = 1 8位灰度? – indira 2012-03-01 10:28:00