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