【问题标题】:Scaled QPixmap looks bad缩放的 QPixmap 看起来很糟糕
【发布时间】:2012-12-03 04:33:52
【问题描述】:

我有以下小部件:

pixmap = QtGui.QPixmap(r'pics\cdaudio.png').scaled(100, 100)

图片从 256x256 缩小。它看起来很波涛汹涌:

如何在 Qt 中平滑地扩展它?

【问题讨论】:

  • 你有没有偶然看过文档?
  • 不知道 scaled 获取分辨率旁边的参数。谢谢

标签: python pyqt pyqt4 qpixmap


【解决方案1】:

使用transformMode参数:

pixmap = QtGui.QPixmap(r'pics\cdaudio.png').scaled(100, 100, transformMode=QtCore.Qt.SmoothTransformation)

【讨论】:

    【解决方案2】:

    根据@iTayb,这是我想出的:

    // Scale the source to the requested size with 
    //  the KeepAspectRatio as aspectMode & SmoothTransformation as mode
    *source = source->scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
    target->setPixmap(*source);
    

    【讨论】:

      【解决方案3】:

      如果可能,为什么不使用 SVG 格式(以及 Qt SVG 模块)?

      【讨论】:

      • 谁说我的源是 SVG?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多