you do not have to do any conversion, just access the data with the right pointer.
First you might be aware that you have a header which preceed the data.
After having loaded the whole dataset, you might read the header and extract at least the number of pixels and the offset of the pixel data within the file.
// read the file content into the byte array
int dataCount; // number of pixels, extracted from header
int dataOffset; // data offset, extracted from header
// initialize both values
//Now get an integer pointer onto the data:
int* pData = reinterpret_cast<int*>(myBmp.data())
// and access the data
for ( int i = 0; i < dataCount; ++i ) { // do it for each pixel
pData[ dataOffset + i] ... // pData points to the pixel number i and returns an integer
}
QByteArray myBmp;
// read the file content into the byte array
int dataCount; // number of pixels, extracted from header
int dataOffset; // data offset, extracted from header
// initialize both values
//Now get an integer pointer onto the data:
int* pData = reinterpret_cast<int*>(myBmp.data())
// and access the data
for ( int i = 0; i < dataCount; ++i ) { // do it for each pixel
pData[ dataOffset + i] ... // pData points to the pixel number i and returns an integer
}
To copy to clipboard, switch view to plain text mode
Bookmarks