【发布时间】:2014-06-04 03:47:00
【问题描述】:
当我在 Qt 中旋转图像时,它会自动放大图像以封装更大的尺寸,非常智能。但是,它用白色填充了新创建的空白,这不是我想要的。如何让它填充完全透明的颜色?
这是可能的代码。
QImage lSource("/path/to/an/image/file");
QTransform lRotation;
lRotation.rotate(30.0);
QImage lRotated(lSource.transformed(lRotation, Qt::SmoothTransformation));
ui.labelImage->setPixmap(QPixmap::fromImage(lRotated));
非常感谢!
【问题讨论】:
-
我怀疑,旋转图像的空白区域是透明的,白色是标签的背景颜色。您希望在那里看到什么颜色?
-
感谢您的及时回复!你是对的。这是标签的背景。我的错。