Opps, I already got the answer, haha a simple mistake, but just to share, I should use the overloaded constructor of QImage to specify the width, height and format
QImage image
(50,
50,
QImage::Format_RGB32);
// use the overloaded constructor QRgb value;
// a 2d array named arr with size 50 x 50 including its values was declared earlier
for (int i=0;i<maxwidth;i++)
{
for (int j=0;j<maxheight;j++)
{
// set the rgb value based on arrs' value
// set them all the same to make em grayscale?
value = qRgb(arr[i][j],arr[i][j],arr[i][j]);
image.setPixel(i,j,value);
}
}
image.save("test.jpg",".jpg");
QImage image(50,50,QImage::Format_RGB32); // use the overloaded constructor
QRgb value;
// a 2d array named arr with size 50 x 50 including its values was declared earlier
for (int i=0;i<maxwidth;i++)
{
for (int j=0;j<maxheight;j++)
{
// set the rgb value based on arrs' value
// set them all the same to make em grayscale?
value = qRgb(arr[i][j],arr[i][j],arr[i][j]);
image.setPixel(i,j,value);
}
}
image.save("test.jpg",".jpg");
To copy to clipboard, switch view to plain text mode
Bookmarks