I have an Image I am trying to display in a label.
I am using some code like the following:
transformPixels(0,0,1,imheight,imwidth,1);//sets unsigned char** imageData
unsigned char* fullCharArray = new unsigned char[imheight * imwidth];
for (int i = 0 ; i < imheight ; i++)
for (int j = 0 ; j < imwidth ; j++)
fullCharArray[(i*imwidth)+j] = imageData[i][j];
ui
->viewLabel
->setPixmap
(QPixmap::fromImage(*qi,Qt
::AutoColor));
transformPixels(0,0,1,imheight,imwidth,1);//sets unsigned char** imageData
unsigned char* fullCharArray = new unsigned char[imheight * imwidth];
for (int i = 0 ; i < imheight ; i++)
for (int j = 0 ; j < imwidth ; j++)
fullCharArray[(i*imwidth)+j] = imageData[i][j];
QImage *qi = new QImage(fullCharArray, imwidth, imheight, QImage::Format_RGB32);
ui->viewLabel->setPixmap(QPixmap::fromImage(*qi,Qt::AutoColor));
To copy to clipboard, switch view to plain text mode
The imageData array contains a single unsigned char per pixel. It is a grayscale image, not full RGB32, but that format seems to be the closest I have gotten so far. the problem is, my label is only showing a portion of the image, which is large (larger than the screen). How can I make my image scale, keeping the proper proportions, so that it fits in the label? I dont want it to be stretched ot skewed or anything - just the full image, small enough to fit in the label.
Thanks
Bookmarks