qt图片转化为数组(灰度图)
伪代码如下:
unsigned char picbuf2[720][1024];
unsigned char picbuf3[1024*720];
pPixmap=new QPixmap("1.bmp");
QImage image=pPixmap->toImage();
unsigned char *pData=image.bits();
int i,j;
for(i = 0;i < 1024*720*4;i += 4)
{
picbuf3[i/4] = pData[i];
}
for(int i=0;i<720;i++)
{
for(int j=0;j<1024;j++)
{
picbuf2[i][j] = picbuf3[i*1024+j];
}
}
这个picbuf2和picbuf3就是灰度化后的数组