PDA

View Full Version : QPixmap resize problem



khcbabu
17th November 2008, 10:47
i have an image size 640*480, i am trying to resize it to 640*300.

my first try was:
QPixmap pixmap(QPixmap(imagePath));
pixmap.scaledToHeight(300,Qt::SmoothTransformation );
qDebug()<<pixmap.size();

but it also change width scale.---

then I tried
QIcon icon;
QSize size(640,300);
QImage image(QImage(imagePath));
icon.addPixmap(QPixmap::fromImage(image), QIcon::Normal, QIcon::On);
QPixmap pixmap = icon.pixmap(size, QIcon::Normal, QIcon::On);

qDebug()<<pixmap.size();

same problem---
any suggession is appreciating....thnks

wysota
17th November 2008, 13:06
Do you want to scale or to crop it? If you want to scale, simply call scaled() with the same width but different height.

khcbabu
17th November 2008, 13:29
pixmap.scaled(640,300,Qt::IgnoreAspectRatio,Qt::Fa stTransformation);

same problem.----width automatically becomes...225
i dont know and I am stucked here....
please help