• 7380阅读
  • 3回复

Qt去除图像的背景色? [复制链接]

上一主题 下一主题
离线不要多話
 
只看楼主 倒序阅读 楼主  发表于: 2009-10-28
       现在有几个png的图案,不过他的背景色是红色,我想利用QPixmap里面的遮罩去除掉背景色,
       不过试了一下完全没作用,请问有人熟Qt图型处理的类吗?
      原码:

         QLabel label;
         QPixmap.pixmap(xxx.png);
          pixmap.createMaskFromColor(QColor(255,0,0),Qt::MaskOutColor);
          label->setPixmap(pixmap);

         是我的用法错误吗?拜托了举个例子让我学习
离线hiti_tony
只看该作者 1楼 发表于: 2009-10-28
QPixmap pixmap("c:/6.JPG");
    QBitmap bmp=pixmap.createMaskFromColor(QColor(0,0,0));
    pixmap.setMask(bmp);
    QLabel *label=new QLabel(this);
    label->setGeometry(100,100,100,100);
    label->setScaledContents(true);
    label->setPixmap(pixmap);
离线hiti_tony
只看该作者 2楼 发表于: 2009-10-29
所以可能你少了setMask这一步吧!
离线午小夜

只看该作者 3楼 发表于: 2009-10-29
QWidget::setAttribute(Qt::WA_TranslucentBackground);

Indicates that the widget should have a translucent background, i.e., any non-opaque regions of the widgets will be translucent because the widget will have an alpha channel. Setting this flag causes WA_NoSystemBackground to be set. On Windows the widget also needs the Qt::FramelessWindowHint window flag to be set. This flag is set or cleared by the widget's author.
[操作系统版本]  Windows XP;Linux Ubuntu;Linux Fedora;
[Qt SDK版本]    4.7.0
[SDK 发布日期]  2010.05
[IDE(集成开发环境)] QtCreator
个人网页:http://hi.baidu.com/午小夜
學歷:Royal Jalidon
快速回复
限100 字节
 
上一个 下一个