View Full Version : pixel of Image display
YDYD
17th July 2014, 05:51
Hi all,
I am displaying Image that i get from camera on QLabel as QImage,
How to make sure that the size of QImage is exactly the size i want in Pixel?
stampede
17th July 2014, 08:38
How to make sure that the size of QImage is exactly the size i want in Pixel?
QImage image = ...;
int width = ...;
int height = ...;
QImage scaledImage = image.scaled(width, height, ...);
YDYD
17th July 2014, 08:53
Erm... i did tried this.
frame=cvQueryFram(cam);
cloneFrame=cvCloneImage(frame);
image=Qimage((const uchar*)cloneFrame->imageData,cloneFrame->width,cloneFrame->height,QImage::Format_RGB888),rgbSwapped();
image = image.scaled(ui->original->size(),
Qt::KeepAspectRatio,
Qt::SmoothTransformation); // my QLabel size is (320,240)
qPainter = newQPainter(&image);
qPainter -> begin(this);
qPainter->setPen(QPen(Qt::red,1,Qt::SolidLine));
qPainter->drawRect(0,0,319,239); //can't see the box since (319,239),
qPainter->end();
ui->original->setPixmap(qPixmap::fromImage(image));
I can't see my box out of (319,239)
stampede
17th July 2014, 09:19
I guess thats why
1) qPainter = new QPainter(&image);
2) qPainter -> begin(this);
line 1) - painter will draw on image
line 2) - now painter will draw on current widget, probably outside of paintEvent so you can't see the result
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.