在QT4里面, 我想对图像进行放大。 用了如下代码:
a. 使用QPixmap的方式:
QPalette pal;
[pre] QString filename=":/photos/1.jpg";[/pre][pre] QPixmap pixmap(filename);[pre] pixmap.scaled(800, 480, Qt::IgnoreAspectRatio, Qt::FastTransformation);[/pre][pre] pal.setBrush(QPalette::Window, QBrush(pixmap));[pre] setPalette(pal);[/pre][pre][/pre][pre]b. 使用QImage的方式: [/pre][pre] QPalette pal;[pre] QString filename=":/photos/1.jpg";[/pre][pre] QImage image(filename);[pre] image.scaled(800, 480, Qt::IgnoreAspectRatio, Qt::FastTransformation);[/pre][pre] pal.setBrush(QPalette::Window, QBrush(image));[pre] setPalette(pal);[/pre][pre][/pre][pre]c. 使用QPixmap 与 QImage的方式: [/pre][pre] QPalette pal;[pre] QString filename=":/photos/1.jpg";[/pre][pre] QPixmap pixmap(filename);[/pre][pre] pixmap.scaled(800, 480, Qt::IgnoreAspectRatio, Qt::FastTransformation);[/pre][pre] QImage image = pixmap.toImage();[/pre][pre] image.scaled(800,480,Qt::IgnoreAspectRatio, Qt::FastTransformation);[/pre][pre] pixmap.convertFromImage(image, Qt::AutoColor);[/pre][pre] pal.setBrush(QPalette::Window, QBrush(image));[/pre][pre] setPalette(pal);[/pre][pre]以上3种方式都不能进行放大。 [/pre][/pre][/pre][/pre][/pre][pre][/pre][pre]我在QT3的程序里面是可以实现放大的, 代码如下:[/pre][pre]QString filename = "images/bgpic.jpg";[/pre][pre]QPixmap pixmap(filename);
QImage image = pixmap.convertToImage();
image = image.scale(640,480, QImage::ScaleFree);
pixmap.convertFromImage(image, QPixmap::Auto);[/pre][pre][/pre][pre]请高手说说在Qt4里面使用QPalette显示图片的方式如何进行放大处理。[/pre][/pre][/pre]