首页 > 其他分享 >QPixmap QImage

QPixmap QImage

时间:2023-01-02 15:12:58浏览次数:56  
标签:pixmap fromImage img gray QPixmap QImage

QPixmap   QImage

 

void ScrollBox::setThumbnail(QPixmap img)
{
    QPixmap bkPixmap  = img.fromImage(img.toImage().scaled(size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
    QPalette palette;
    palette.setBrush(backgroundRole(), bkPixmap);
    setPalette(palette);

    // Qt3
    //setPaletteBackgroundPixmap(img.fromImage(img.toImage().scaled(size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation)));
}

 

void ICQPicture::setPict(QImage &img)
{
    if (img.isNull()){
        lblPict->setText(i18n("Picture is not available"));
        return;
    }
    QPixmap pict;
    pict.fromImage(img);
    lblPict->setPixmap(pict);
    lblPict->setMinimumSize(pict.size());
}

 

// experimental
QPixmap PrintLayout::convertPixmapToGrayscale(QPixmap pixmap) const
{
    QImage image = pixmap.toImage();
    int gray, width = pixmap.width(), height = pixmap.height();
    for (int i = 0; i < width; i++) {
        for (int j = 0; j < height; j++) {
            gray = qGray(image.pixel(i, j));
            image.setPixel(i, j, qRgb(gray, gray, gray));
        }
    }
    return pixmap.fromImage(image);
}

 

 

 

 

来自:https://cpp.hotexamples.com/zh/examples/-/QPixmap/fromImage/cpp-qpixmap-fromimage-method-examples.html

#############################

标签:pixmap,fromImage,img,gray,QPixmap,QImage
From: https://www.cnblogs.com/herd/p/17019920.html

相关文章

  • QImage 深拷贝 浅拷贝
    //浅拷贝QImage(uchar*data,intwidth,intheight,Formatformat)//浅拷贝QImage(constuchar*data,intwidth,intheight,Formatformat)//浅拷贝QImag......
  • QImage
    QImage是用于读写绘制图像的基本类库,显示图像,我们借助于QImage,重点是如何通过图像二维数组(或三维数组)构造一个QImage对象。以下来至于QImage构造函数QImage::QImage(ucha......
  • QPixmap::fromImage(img)访问冲突
     我是在将图像格式转换为QImage后,把QImage发送给UI界面显示时出现的问题。 加了个深拷贝,就解决了。OutImage=QImage(buffer,width,height,QImage::Format_RGB88......