uchar* buff = (uchar*)pInBuffer->GetBuffer();
int nHeight = pInBuffer->GetHeight();
int nWidth = pInBuffer->GetWidth();
QImage imgBuff(buff, nWidth, nHeight, QImage::Format_Indexed8);
OutImage = imgBuff;
uchar* pCursor = OutImage.bits();
for ( int y=0; y<nHeight; ++y ) {
pCursor = OutImage.scanLine( y );
for ( int x=0; x<nWidth; ++x ) {
*pCursor =* buff;
++pCursor;
++buff;
}
}
其中, scanLine(int)来获取qimage每行的首地址
另外bytesPerLine(); 可以获取Qimage在数据对齐之后每行真实的字节数
因为位图保存到磁盘时规定图片的数据每行的字节数要能被4整除

本文详细解析了如何使用QImage的scanLine()函数获取每行的首地址,并通过bytesPerLine()函数获取每行实际的字节数。重点介绍了如何在位图数据处理中,确保图片数据每行字节数符合4字节对齐的要求。
1086

被折叠的 条评论
为什么被折叠?



