Hi all,

I have a problem in saving QImage as 2Dimensional array in a ".txt" file. I have tried the following but it doesn't work. Would be honoured to have your guidance.

@

QPixmap p(scn3->width(),scn3->height());
QPainter paint(&p);
paint.setRenderHint(QPainter::Antialiasing);
paint.setRenderHint(QPainter::SmoothPixmapTransfor m);
scn3->render(&paint);
QImage img=p.toImage();

int width=img.width();

int height=img.height();
int matrix[width][height];
for(int j=0;j<width;j++)
{
for (int i=0;i<height;i++)
{
matrix[i][j]=qRed(img.pixel(i,j));
// matrix[j*width+i]=qGray(img.pixel(i,j));

}
}
//unsigned char* data=img.bits();
QFile f("/Users/venkateshpadmanabhan/Desktop/out1.txt");
f.open(QIODevice::WriteOnly | QIODevice::Append);
QDataStream s(&f);
s<<qint64(matrix[100][100]);
f.close();

@

I needed it to store in a file for image manipulation for medical image processing.