QString VPreviewManager::imageResourceName(const ImageLinkInfo &p_link) { // Add size info to the name. QString name = QString("%1_%2_%3").arg(p_link.m_linkShortUrl) .arg(p_link.m_width) .arg(p_link.m_height); if (m_editor->containsImage(name)) { return name; } // Add it to the resource. QPixmap image; QString imgPath = p_link.m_linkUrl; if (QFileInfo::exists(imgPath)) { // Local file. image = VUtils::pixmapFromFile(imgPath); } else { // URL. Try to download it. m_downloader->download(imgPath); m_urlToName.insert(imgPath, name); } if (image.isNull()) { return QString(); } // Resize the image. Qt::TransformationMode tMode = Qt::SmoothTransformation; qreal sf = VUtils::calculateScaleFactor(); if (p_link.m_width > 0) { if (p_link.m_height > 0) { m_editor->addImage(name, image.scaled(p_link.m_width * sf, p_link.m_height * sf, Qt::IgnoreAspectRatio, tMode)); } else { m_editor->addImage(name, image.scaledToWidth(p_link.m_width * sf, tMode)); } } else if (p_link.m_height > 0) { m_editor->addImage(name, image.scaledToHeight(p_link.m_height * sf, tMode)); } else { if (sf < 1.1) { m_editor->addImage(name, image); } else { m_editor->addImage(name, image.scaledToWidth(image.width() * sf, tMode)); } } return name; }
IntroPage::IntroPage(KAssistantDialog* dlg) : KIPIPlugins::WizardPage(dlg, i18n("Welcome to Exposure Blending Tool")) { KVBox *vbox = new KVBox(this); QLabel *title = new QLabel(vbox); title->setWordWrap(true); title->setOpenExternalLinks(true); title->setText(i18n("<qt>" "<p><h1><b>Welcome to Exposure Blending tool</b></h1></p>" "<p>This tool fuses bracketed images with different exposure to make pseudo " "<a href='http://en.wikipedia.org/wiki/High_dynamic_range_imaging'>HDR image</a>.</p>" "<p>It can also be used to merge focus bracketed stack to get a single image " "with increased depth of field.</p>" "<p>This assistant will help you to configure how to import images before " "merging them to a single one.</p>" "<p>Bracketed images must be taken with the same camera, " "in the same conditions, and if possible using a tripod.</p>" "<p>For more information, please take a look at " "<a href='http://en.wikipedia.org/wiki/Bracketing'>this page</a></p>" "</qt>")); setPageWidget(vbox); QPixmap leftPix = KStandardDirs::locate("data", "kipiplugin_expoblending/pics/assistant-tripod.png"); setLeftBottomPix(leftPix.scaledToWidth(128, Qt::SmoothTransformation)); }
void QUrlModel::setUrl(const QModelIndex &index, const QUrl &url, const QModelIndex &dirIndex) { setData(index, url, UrlRole); if (url.path().isEmpty()) { setData(index, fileSystemModel->myComputer()); setData(index, fileSystemModel->myComputer(Qt::DecorationRole), Qt::DecorationRole); } else { QString newName = dirIndex.data().toString(); QIcon newIcon = qvariant_cast<QIcon>(dirIndex.data(Qt::DecorationRole)); if (!dirIndex.isValid()) { newIcon = fileSystemModel->iconProvider()->icon(QFileIconProvider::Folder); newName = QFileInfo(url.toLocalFile()).fileName(); if (!invalidUrls.contains(url)) invalidUrls.append(url); } // Make sure that we have at least 32x32 images const QSize size = newIcon.actualSize(QSize(32, 32)); if (size.width() < 32) { QPixmap smallPixmap = newIcon.pixmap(QSize(32, 32)); newIcon.addPixmap(smallPixmap.scaledToWidth(32, Qt::SmoothTransformation)); } if (index.data().toString() != newName) setData(index, newName); QIcon oldIcon = qvariant_cast<QIcon>(index.data(Qt::DecorationRole)); // if (oldIcon.cacheKey() != newIcon.cacheKey()) setData(index, newIcon, Qt::DecorationRole); } }
void ImageDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QStyledItemDelegate::paint(painter,option, index); QString filename = index.data().toString(); if(filename != "") { QStyleOptionViewItemV4 options = option; initStyleOption(&options, index); QImage image(filename); if (image.isNull()) return; painter->save(); QSize imageSize = options.icon.actualSize(options.rect.size()); imageSize.scale(imageSize.width(), imageSize.height(), Qt::KeepAspectRatioByExpanding); painter->translate(options.rect.left() + imageSize.width(), options.rect.top()); QPixmap pix = QPixmap::fromImage(image); pix = pix.scaledToHeight(options.rect.height(), Qt::SmoothTransformation); if (pix.width() > options.rect.width()) pix = pix.scaledToWidth(options.rect.width(), Qt::SmoothTransformation); painter->drawPixmap(0,0,pix); painter->restore(); } }
LastPage::LastPage(Manager* const mngr, KAssistantDialog* const dlg) : KPWizardPage(dlg, i18n("Pre-Processing is Complete")), d(new Private) { d->mngr = mngr; KVBox* const vbox = new KVBox(this); QLabel* const title = new QLabel(vbox); title->setOpenExternalLinks(true); title->setWordWrap(true); title->setText(i18n("<qt>" "<p><h1><b>Bracketed Images Pre-Processing is Done</b></h1></p>" "<p>Congratulations. Your images are ready to be fused. </p>" "<p>To perform this operation, <b>%1</b> program from " "<a href='%2'>Enblend</a> " "project will be used.</p>" "<p>Press \"Finish\" button to fuse your items and make a pseudo HDR image.</p>" "</qt>", QDir::toNativeSeparators(d->mngr->enfuseBinary().path()), d->mngr->enfuseBinary().url().url())); QLabel* const space = new QLabel(vbox); vbox->setStretchFactor(space, 10); setPageWidget(vbox); QPixmap leftPix = KStandardDirs::locate("data", "kipiplugin_expoblending/pics/assistant-enfuse.png"); setLeftBottomPix(leftPix.scaledToWidth(128, Qt::SmoothTransformation)); }
void MovieTickets::on_edit_image_clicked(){ QString image_name(this->window.edit_image_lineEdit->text()); QPixmap* image; if(image_name.length() > 0){ QString image_full_path(this->image_path); image_full_path.append(image_name); image = new QPixmap(image_full_path); if(image->isNull()){ image = new QPixmap("..\\Data\\Images\\no_movie.jpg"); } } else{ image = new QPixmap("..\\Data\\Images\\no_movie.jpg"); } QPixmap aux = image->scaledToWidth(this->window.edit_image_label->width()); if(aux.height() > this->window.edit_image_label->height()){ aux = image->scaledToHeight(this->window.edit_image_label->height()); } this->window.edit_image_label->setPixmap(aux); }
void ThumbnailLabel::paintEvent(QPaintEvent *event) { int w = width(); int h = height(); QStyleOption o; QPainter p; event->accept(); o.initFrom(this); p.begin(this); style()->drawPrimitive( QStyle::PE_Widget, &o, &p, this); p.end(); if (!m_pixmap || m_pixmap->isNull()) { m_pixmap = new QPixmap(sizeHint()); m_pixmap->fill(QColor(0, 0, 0, 0)); } if (w > 0 && h > 0 && m_pixmap && !m_pixmap->isNull()) { int newHeight = (m_pixmap->height() / static_cast<float>(m_pixmap->width())) * width(); QPixmap pixmapScaled = *m_pixmap; QPixmap pixmap; QPainter pScale; int pw = 0; int ph = 0; unsigned *buf = new unsigned[w * h]; if (newHeight > h) pixmapScaled = pixmapScaled.scaledToHeight(h, Qt::SmoothTransformation); else pixmapScaled = pixmapScaled.scaledToWidth(w, Qt::SmoothTransformation); pw = pixmapScaled.width(); ph = pixmapScaled.height(); pixmap = QPixmap(w, h); pixmap.fill(QColor(0, 0, 0, 0)); pScale.begin(&pixmap); pScale.drawPixmap(QRect((w - pw) / 2, (h - ph) / 2, pw, ph), pixmapScaled, pixmapScaled.rect()); pScale.end(); if (!pixmap.isNull()) { p.begin(this); p.drawPixmap(rect(), pixmap, pixmap.rect()); p.end(); } delete []buf; } else QWidget::paintEvent(event); }
PreProcessingPage::PreProcessingPage(Manager* const mngr, KAssistantDialog* const dlg) : KPWizardPage(dlg, i18n("<b>Pre-Processing Images</b>")), d(new PreProcessingPagePriv) { d->mngr = mngr; d->progressTimer = new QTimer(this); KVBox* vbox = new KVBox(this); d->title = new QLabel(vbox); d->title->setWordWrap(true); d->title->setOpenExternalLinks(true); KConfig config("kipirc"); KConfigGroup group = config.group(QString("Panorama Settings")); d->celesteCheckBox = new QCheckBox(i18n("Detect moving skies"), vbox); d->celesteCheckBox->setChecked(group.readEntry("Celeste", false)); d->celesteCheckBox->setToolTip(i18n("Automatic detection of clouds to prevent wrong keypoints matching " "between images due to moving clouds.")); d->celesteCheckBox->setWhatsThis(i18n("<b>Detect moving skies</b>: During the control points selection and matching, " "this option discards any points that are associated to a possible cloud. This " "is useful to prevent moving clouds from altering the control points matching " "process.")); QLabel* space1 = new QLabel(vbox); KHBox* hbox = new KHBox(vbox); d->detailsBtn = new QPushButton(hbox); d->detailsBtn->setText(i18n("Details...")); d->detailsBtn->hide(); QLabel* space2 = new QLabel(hbox); hbox->setStretchFactor(space2, 10); QLabel* space3 = new QLabel(vbox); d->progressLabel = new QLabel(vbox); d->progressLabel->setAlignment(Qt::AlignCenter); QLabel* space4 = new QLabel(vbox); vbox->setStretchFactor(space1, 2); vbox->setStretchFactor(space3, 2); vbox->setStretchFactor(space4, 10); vbox->setSpacing(KDialog::spacingHint()); vbox->setMargin(KDialog::spacingHint()); setPageWidget(vbox); resetTitle(); QPixmap leftPix = KStandardDirs::locate("data", "kipiplugin_panorama/pics/assistant-preprocessing.png"); setLeftBottomPix(leftPix.scaledToWidth(128, Qt::SmoothTransformation)); // connect(d->mngr->thread(), SIGNAL(starting(KIPIPanoramaPlugin::ActionData)), // this, SLOT(slotAction(KIPIPanoramaPlugin::ActionData))); connect(d->progressTimer, SIGNAL(timeout()), this, SLOT(slotProgressTimerDone())); connect(d->detailsBtn, SIGNAL(clicked()), this, SLOT(slotShowDetails())); }
void MainWindow::setImg() { if(!this->imgdir.dirExist || this->imgdir.fileList.length() == 0) { QPixmap empty; ui->imgLabel->setPixmap(empty); if(!this->imgdir.dirExist) ui->imgLabel->setText("Path is invalid, is not a directory?"); else ui->imgLabel->setText("Couldn't find any image in the directory"); return; } // in case index is outbounds, should not happen if(index > imgdir.fileList.count()) return; QString temp = imgdir.dir.absoluteFilePath(imgdir.fileList.value(index)); dbg << imgdir.fileList.value(index).toStdString().c_str() << std::endl; dbg << temp.toStdString().c_str() << std::endl; dbg << index << std::endl; QPixmap imgtemp; imgtemp.load(temp.toStdString().c_str()); if(scaleImg) { if(imgtemp.height() > program_settings.retrive_as_int(MAX_HEIGHT_SETT)) imgtemp = imgtemp.scaledToHeight( program_settings.retrive_as_int(MAX_HEIGHT_SETT), Qt::SmoothTransformation); if(imgtemp.width() > program_settings.retrive_as_int(MAX_WIDTH_SETT)) imgtemp = imgtemp.scaledToWidth( program_settings.retrive_as_int(MAX_WIDTH_SETT), Qt::SmoothTransformation); } if(temp.endsWith(".gif",Qt::CaseInsensitive) || temp.endsWith(".webm",Qt::CaseInsensitive)) // not yet support for webm { QMovie *movie = new QMovie(temp.toStdString().c_str()); ui->imgLabel->setMovie(movie); movie->start(); dbg << "movie" << std::endl; }else { ui->imgLabel->setPixmap(imgtemp); } adjustScrollArea(); imgdir.saveIndex(imgdir.buildPath( program_settings.retrive(DIR1_SETT),"i.txt").c_str(), index); updateFileName(); coutdebug(); }
QPixmap MovieLabel::scaledPixmap(const QPixmap& pix) { if (pix.isNull()) return pix; if (pix.width()/(double)width() < pix.height()/(double)height()) return pix.scaledToHeight(height()); else return pix.scaledToWidth(width()); }
QIcon IndigoTabbar::rotateIcon(const QIcon &icon, TabPosition tabPos){ QSize sz; for (int var = 0; var < icon.availableSizes().count(); ++var) { if (icon.availableSizes().at(var).width() > sz.width()) sz = icon.availableSizes().at(var); } QPixmap pix = icon.pixmap(sz); QTransform trans; switch(this->tabPosition()){ case QTabWidget::East:{ switch(tabPos){ case QTabWidget::West:{ trans.rotate(180); break; } case QTabWidget::North:{ trans.rotate(-90); break; } default: break; } break; } case QTabWidget::West:{ switch(tabPos){ case QTabWidget::East:{ trans.rotate(180); break; } case QTabWidget::North:{ trans.rotate(+90); break; } default: break; } break; } default: break; } pix = pix.transformed(trans); pix = pix.scaledToWidth( iconScale ); pix = pix.scaledToHeight( iconScale ); return QIcon(pix); }
void ImageRectificator::rectifyFromProjToSim() { if (projectedImageLabel->getSelectedPixels()->size() < 20) { QMessageBox::information(this, tr("Image Rectificator"), tr("%1 pixels should be selected before rectification.").arg(m_maxSelectedPixels)); return; } QPixmap rectifiedPixmap = RectificationController::toSimilarityFromProjection(projectedImageLabel); rectifiedImageLabel->setPixmap(rectifiedPixmap.scaledToWidth(640)); rectifiedImageLabel->adjustSize(); }
void LobbyWidget::mapSelected(const QString& path) { QPixmap *pixmap = new QPixmap(path); level->setPixmap(pixmap->scaledToWidth(level->x(), Qt::SmoothTransformation)); /* restarting the files dialog */ files = new QFileDialog(); grid->addWidget(files, 0, 0, 3, 1); files->setNameFilter(tr("Images (*.png *.jpg)")); connect(files, SIGNAL(fileSelected(const QString&)), this, SLOT(mapSelected(const QString&))); /* storing the path */ this->path = path; }
void AppearanceSettings::previewColorChanges() { Theme *theme = currentTheme(); if (theme) { QPixmap pm; theme->getTitlePreview(&pm); m_previewTitle->setPixmap( pm.scaledToWidth(int(pm.width() * 0.55), Qt::SmoothTransformation)); previewSoftMenuBarChanges(); m_previewBox->show(); } }
void AppearanceSettings::previewSoftMenuBarChanges() { Theme *theme = currentTheme(); if (theme) { QPixmap pm; QSoftMenuBar::LabelType labelType = (m_softKeyIconCheck->isChecked() ? QSoftMenuBar::IconLabel : QSoftMenuBar::TextLabel); theme->getSoftMenuBarPreview(&pm, labelType); m_previewSoftMenuBar->setPixmap( pm.scaledToWidth(int(pm.width() * 0.55), Qt::SmoothTransformation)); m_previewBox->show(); } }
bool VideoPreview::addPicture(const QString &filename, int num, int time) { int row = num / prop.n_cols; int col = num % prop.n_cols; qDebug("VideoPreview::addPicture: %d (row: %d col: %d) file: '%s'", num, row, col, filename.toUtf8().constData()); QPixmapCache::clear(); QPixmap picture; if (!picture.load(filename)) { qDebug("VideoPreview::addPicture: can't load file"); error_message = tr("The file %1 can't be loaded").arg(filename); return false; } if (run.thumbnail_width == 0) { int spacing = grid_layout->horizontalSpacing() * (prop.n_cols - 1); if (spacing < 0) spacing = 0; qDebug("VideoPreview::addPicture: spacing: %d", spacing); run.thumbnail_width = (prop.max_width - spacing) / prop.n_cols; if (run.thumbnail_width > picture.width()) run.thumbnail_width = picture.width(); qDebug("VideoPreview::addPicture: thumbnail_width set to %d", run.thumbnail_width); } QPixmap scaled_picture = picture.scaledToWidth(run.thumbnail_width, Qt::SmoothTransformation); // Add current time text if (prop.display_osd) { QString stime = QTime().addSecs(time).toString("hh:mm:ss"); QFont font("Arial"); font.setBold(true); QPainter painter(&scaled_picture); painter.setPen(Qt::white); painter.setFont(font); painter.drawText(scaled_picture.rect(), Qt::AlignRight | Qt::AlignBottom, stime); } QLabel *l = new QLabel(this); label_list.append(l); l->setPixmap(scaled_picture); //l->setPixmap(picture); grid_layout->addWidget(l, row, col); return true; }
PreProcessingPage::PreProcessingPage(Manager* const mngr, KAssistantDialog* const dlg) : KPWizardPage(dlg, i18n("<b>Pre-Processing Bracketed Images</b>")), d(new PreProcessingPagePriv) { d->mngr = mngr; d->progressTimer = new QTimer(this); KVBox *vbox = new KVBox(this); d->title = new QLabel(vbox); d->title->setWordWrap(true); d->title->setOpenExternalLinks(true); d->alignCheckBox = new QCheckBox(i18n("Align bracketed images"), vbox); KConfig config("kipirc"); KConfigGroup group = config.group(QString("ExpoBlending Settings")); d->alignCheckBox->setChecked(group.readEntry("Auto Alignment", true)); QLabel* space1 = new QLabel(vbox); KHBox* hbox = new KHBox(vbox); d->detailsBtn = new QPushButton(hbox); d->detailsBtn->setText(i18n("Details...")); d->detailsBtn->hide(); QLabel* space2 = new QLabel(hbox); hbox->setStretchFactor(space2, 10); QLabel* space3 = new QLabel(vbox); d->progressLabel = new QLabel(vbox); d->progressLabel->setAlignment(Qt::AlignCenter); QLabel* space4 = new QLabel(vbox); vbox->setStretchFactor(space1, 2); vbox->setStretchFactor(space3, 2); vbox->setStretchFactor(space4, 10); vbox->setSpacing(KDialog::spacingHint()); vbox->setMargin(KDialog::spacingHint()); setPageWidget(vbox); resetTitle(); QPixmap leftPix = KStandardDirs::locate("data", "kipiplugin_expoblending/pics/assistant-preprocessing.png"); setLeftBottomPix(leftPix.scaledToWidth(128, Qt::SmoothTransformation)); connect(d->mngr->thread(), SIGNAL(starting(KIPIExpoBlendingPlugin::ActionData)), this, SLOT(slotAction(KIPIExpoBlendingPlugin::ActionData))); connect(d->progressTimer, SIGNAL(timeout()), this, SLOT(slotProgressTimerDone())); connect(d->detailsBtn, SIGNAL(clicked()), this, SLOT(slotShowDetails())); }
ContactItemWidget::ContactItemWidget(const Contact * contact, bool displayPhoto, QWidget *parent) : QWidget(parent) { if(!contact->getNickName().isEmpty()) { contactName = new QLabel(contact->getNickName()); } else { contactName = new QLabel(contact->getFirstName()); } if(displayPhoto) { if(!contact->getPhoto()->isEmpty()) { QPixmap pixmap; if(contact->getPhoto()->isIntern()) { contactPhoto = new QLabel(); pixmap = QPixmap::fromImage(contact->getPhoto()->data()); } else { contactPhoto = new QLabel(); pixmap = QPixmap(contact->getPhoto()->url()); } if(pixmap.height() > pixmap.width()) contactPhoto->setPixmap(pixmap.scaledToHeight(CONTACT_ITEM_HEIGHT-4)); else contactPhoto->setPixmap(pixmap.scaledToWidth(CONTACT_ITEM_HEIGHT-4)); } else { contactPhoto = new QLabel(); contactPhoto->setMinimumSize(CONTACT_ITEM_HEIGHT-4, 0); } } contactType = new QLabel(PhoneNumber::typeLabel(contact->getType())); contactNumber = new QLabel(contact->getPhoneNumber()); QSpacerItem * horizontalSpacer = new QSpacerItem(16777215, 20, QSizePolicy::Preferred, QSizePolicy::Minimum); QHBoxLayout * hlayout = new QHBoxLayout(this); QVBoxLayout * vlayout = new QVBoxLayout(); hlayout->setMargin(1); hlayout->setSpacing(4); vlayout->setMargin(1); vlayout->setSpacing(2); vlayout->addWidget(contactName); vlayout->addWidget(contactNumber); if(displayPhoto) { hlayout->addWidget(contactPhoto); } hlayout->addLayout(vlayout); hlayout->addItem(horizontalSpacer); hlayout->addWidget(contactType); this->setLayout(hlayout); }
void ImageDisplayDialog::setPixmap(const QPixmap &image) { if (! started) { started = true; myTimer.restart(); overallTimer.restart(); oldtitle = this->windowTitle(); images = 0; cimages = 0; } #ifdef RESIZEME QSize s = image.size(); int maxval = 768; if ( s.width() > s.height()) ui->label->setPixmap( image.scaledToWidth(maxval) ); else ui->label->setPixmap (image.scaledToHeight(maxval) ); #else ui->label->setPixmap(image); #endif images++; cimages++; if (images % 10 == 0) { QString fps; int time = myTimer.elapsed(); int ctime = 1; if (time == 0) time = 1; if ( overallTimer.elapsed() > 2000 ) { ctime = overallTimer.elapsed(); fpsstr.sprintf("%5.2f", cimages * 1000.0 / ctime); cimages = 0; overallTimer.restart(); } fps.sprintf(" - %s FPS - %d seconds running - %d images captured ", fpsstr.toStdString().c_str(), time / 1000, images); this->setWindowTitle(oldtitle + fps); } }
void QUrlModel::setUrl(const QModelIndex &index, const QUrl &url, const QModelIndex &dirIndex) { setData(index, url, UrlRole); if (url.path().isEmpty()) { setData(index, fileSystemModel->myComputer()); setData(index, fileSystemModel->myComputer(Qt::DecorationRole), Qt::DecorationRole); } else { QString newName; if (showFullPath) { //On windows the popup display the "C:\", convert to nativeSeparators newName = QDir::toNativeSeparators(dirIndex.data(QFileSystemModel::FilePathRole).toString()); } else { newName = dirIndex.data().toString(); } QIcon newIcon = qvariant_cast<QIcon>(dirIndex.data(Qt::DecorationRole)); if (!dirIndex.isValid()) { const QFileIconProvider *provider = fileSystemModel->iconProvider(); if (provider) newIcon = provider->icon(QFileIconProvider::Folder); newName = QFileInfo(url.toLocalFile()).fileName(); if (!invalidUrls.contains(url)) invalidUrls.append(url); //The bookmark is invalid then we set to false the EnabledRole setData(index, false, EnabledRole); } else { //The bookmark is valid then we set to true the EnabledRole setData(index, true, EnabledRole); } // Make sure that we have at least 32x32 images const QSize size = newIcon.actualSize(QSize(32,32)); if (size.width() < 32) { QPixmap smallPixmap = newIcon.pixmap(QSize(32, 32)); newIcon.addPixmap(smallPixmap.scaledToWidth(32, Qt::SmoothTransformation)); } if (index.data().toString() != newName) setData(index, newName); QIcon oldIcon = qvariant_cast<QIcon>(index.data(Qt::DecorationRole)); if (oldIcon.cacheKey() != newIcon.cacheKey()) setData(index, newIcon, Qt::DecorationRole); } }
QPixmap MeeGoThemedImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) { QPixmap pixmap; int width = requestedSize.width(); int height = requestedSize.height(); QString themeDir = QString("/usr/share/themes/") + themeItem->value().toString() + "/"; // If we have a custom icon then use it if (QFile::exists(themeDir + id + ".png")) { pixmap.load(themeDir + id + ".png"); if (width > 0 && height > 0) { pixmap = pixmap.scaled(QSize(width, height)); } else if (width > 0) { pixmap = pixmap.scaledToWidth(width); } else if (height > 0) { pixmap = pixmap.scaledToHeight(height); } } else { qDebug() << QString("Failed to find theme image requested: %1").arg(themeDir + id + ".png"); // Return a red pixmap to assist in finding missing images if (width <= 0) width = 100; if (height <= 0) height = 100; pixmap = QPixmap(QSize(width, height)); pixmap.fill(Qt::red); } if (size) *size = pixmap.size(); return pixmap; }
ItemWidget *ItemImageLoader::create(const QModelIndex &index, QWidget *parent) const { // TODO: Just check if image provided and load it in different thread. QPixmap pix; if ( !getPixmapFromData(index, &pix) ) return NULL; // scale pixmap const int w = m_settings.value("max_image_width", 320).toInt(); const int h = m_settings.value("max_image_height", 240).toInt(); if ( w > 0 && pix.width() > w && (h <= 0 || pix.width()/w > pix.height()/h) ) { pix = pix.scaledToWidth(w); } else if (h > 0 && pix.height() > h) { pix = pix.scaledToHeight(h); } return new ItemImage(pix, m_settings.value("image_editor").toString(), m_settings.value("svg_editor").toString(), parent); }
void PdfThumbProvider::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, ThumbWidget *widget) { if ( widget && painter ) { int pageIndex = widget->getPageIndex(); QRectF expsRect = option->exposedRect; expsRect.setTopLeft(QPointF(0,0)); if ((!painter->clipRegion().isEmpty()) && (!painter->clipRegion().contains(expsRect.toRect()))) { return; } qreal thumbWidth = widget->style()->preferredSize().width(); QPixmap thumbnail; if ( !QPixmapCache::find(widget->key(), &thumbnail) ) { qreal pageWidth = data->loader->pageSize(pageIndex).width(); qreal scale = PdfLoader::DPIPerInch * (thumbWidth / pageWidth); qDebug() << __PRETTY_FUNCTION__ << "getThumbnail"; QImage thumb = data->loader->getThumbnail(pageIndex, scale); if (thumb.isNull()) { widget->startSpinner(expsRect.center()); return; } thumbnail = QPixmap::fromImage(thumb.scaledToWidth(thumbWidth)); m_lastThumbanailSize = QSizeF(thumbnail.size()); widget->setKey(QPixmapCache::insert(thumbnail)); painter->drawPixmap(QPointF(0,0), thumbnail, expsRect); widget->stopSpinner(); } else { if (thumbnail.width() != thumbWidth) { qDebug() << "Thumbnail is scaled to Thumbnail widget "; thumbnail = thumbnail.scaledToWidth(thumbWidth); QPixmapCache::replace(widget->key(), thumbnail); m_lastThumbanailSize = QSizeF(thumbnail.size()); } painter->drawPixmap(QPointF(0,0), thumbnail, expsRect); } if (m_lastThumbanailSize.height() > 0) { widget->setSize(m_lastThumbanailSize, 2); } } }
//trigger when the selection in the model list combo box is changed, display the corresponding new image void DBaseDlg::modelChanged(){ if(inModelConstruction) return; QString psbModelThumbPath = QString( mModelList[mModelMap[modelsComboBox->currentText().toStdString()]]-> ThumbnailPath().c_str() ); if(mModelScene) delete mModelScene; mModelScene = new QGraphicsScene; mModelScene->setBackgroundBrush(Qt::blue); QPixmap lPixmap; lPixmap.load(psbModelThumbPath); //resize so that it will fit in window if (lPixmap.width() > 160) { lPixmap = lPixmap.scaledToWidth(160); } if (lPixmap.height() > 120) { lPixmap = lPixmap.scaledToHeight(120); } mModelScene->addPixmap(lPixmap); this->objectGraph->setScene(mModelScene); this->objectGraph->show(); }
void EWASiteDrawer::makeThumbnailFromImage( QPixmap& srcImg, qreal blurR ) { int iW = srcImg.width(); int iH = srcImg.height(); int iDstDemension = EWAApplication::getScreenSize().width()/5; if( qMax( iW, iH ) > iDstDemension ) { srcImg = iW >= iH ? srcImg.scaledToWidth( iDstDemension, Qt::SmoothTransformation ) : srcImg.scaledToHeight( iDstDemension, Qt::SmoothTransformation ); } QPixmap res( srcImg.width() + blurR + blurR, srcImg.height() + blurR + blurR); res.fill( QToolTip::palette().color( QPalette::Inactive, QPalette::AlternateBase ) ); QPainter p( &res ); p.setRenderHints( EWAApplication::getRenderHints() ); drawShadowedPixmap( &p, srcImg, (res.width()-srcImg.width())/2-blurR/2, (res.height()-srcImg.height())/2-blurR/2, false ); srcImg = res.copy(); }
void Notifications::notify(const QString &text) { if (Config::instance()->notifier() == FREEDESKTOP && m_dbus) { m_dbus = notifyDBus(text); if (m_dbus) // DBus notify succeeded return; DEBUG("DBus notify failed, falling back to custom notifier."); } // TODO: height and width set optionaly QPixmap icon; if (Config::instance()->showCoverArt() && m_coverArt->hasCoverArt()) { icon = m_coverArt->coverArt(); if (icon.height() > 64) icon = icon.scaledToHeight(64, Qt::SmoothTransformation); if (icon.width() > 64) icon = icon.scaledToWidth(64, Qt::SmoothTransformation); } else { icon = QPixmap(":/icons/qmpdclient48.png"); } PassivePopup::Position pos = static_cast<PassivePopup::Position>(Config::instance()->notificationsPosition()); new PassivePopup("QMPDClient", text, icon, pos, Config::instance()->notificationsTimeout()); }
void KDReports::SpreadsheetReportLayout::paintIcon( QPainter& painter, const QRectF& cellContentsRect, const QVariant& cellDecoration ) const { QPixmap pix = qvariant_cast<QPixmap>( cellDecoration ); if ( pix.isNull() ) { pix = qvariant_cast<QIcon>( cellDecoration ).pixmap( m_tableLayout.m_iconSize ); } qreal height = pix.height(); QImage img; if ( pix.isNull() ) { img = qvariant_cast<QImage>( cellDecoration ); if ( img.isNull() ) return; height = img.height(); } // Now either img or pix is set. // Apply scaling factor if ( m_tableLayout.scalingFactor() != 1. ) { if ( !pix.isNull() ) { pix = pix.scaledToWidth( pix.width() * m_tableLayout.scalingFactor() ); height = pix.height(); } else { img = img.scaledToWidth( img.width() * m_tableLayout.scalingFactor() ); height = img.height(); } } // Vertical centering const qreal y = qMax( qreal( 0 ), qreal( ( cellContentsRect.height() - height ) / 2.0 ) ); if ( !img.isNull() ) { // Draw img painter.drawImage( cellContentsRect.x(), cellContentsRect.y() + y, img ); } else { // Draw pix painter.drawPixmap( cellContentsRect.x(), cellContentsRect.y() + y, pix ); } }
ItemsPage::ItemsPage(Manager* const mngr, KAssistantDialog* const dlg) : KPWizardPage(dlg, i18n("<b>Set Bracketed Images</b>")), d(new ItemsPagePriv) { d->mngr = mngr; KVBox* vbox = new KVBox(this); QLabel* label1 = new QLabel(vbox); label1->setWordWrap(true); label1->setText(i18n("<qt>" "<p>Set here the list of your bracketed images to fuse. Please follow these conditions:</p>" "<ul><li>At least 2 images from the same subject must be added to the stack.</li>" "<li>Do not mix images with different color depth.</li>" "<li>All images must have the same dimensions.</li></ul>" "</qt>")); d->list = new KPImagesList(vbox); d->list->listView()->setColumn(KPImagesListView::User1, i18n("Exposure (EV)"), true); d->list->slotAddImages(d->mngr->itemsList()); setPageWidget(vbox); QPixmap leftPix = KStandardDirs::locate("data", "kipiplugin_expoblending/pics/assistant-stack.png"); setLeftBottomPix(leftPix.scaledToWidth(128, Qt::SmoothTransformation)); connect(d->mngr->thread(), SIGNAL(starting(KIPIExpoBlendingPlugin::ActionData)), this, SLOT(slotAction(KIPIExpoBlendingPlugin::ActionData))); connect(d->mngr->thread(), SIGNAL(finished(KIPIExpoBlendingPlugin::ActionData)), this, SLOT(slotAction(KIPIExpoBlendingPlugin::ActionData))); connect(d->list, SIGNAL(signalAddItems(KUrl::List)), this, SLOT(slotAddItems(KUrl::List))); connect(d->list, SIGNAL(signalImageListChanged()), this, SLOT(slotImageListChanged())); QTimer::singleShot(0, this, SLOT(slotSetupList())); }
void CurrentTrack::resizeCover( const QPixmap &cover, qreal width ) { QPixmap coverWithBorders; if( !cover.isNull() ) { const int borderWidth = 5; width -= borderWidth * 2; qreal pixmapRatio = (qreal)cover.width() / width; //center the cover : if the cover is not squared, we get the missing pixels and center coverWithBorders = ( cover.height() / pixmapRatio > width ) ? cover.scaledToHeight( width, Qt::SmoothTransformation ) : cover.scaledToWidth( width, Qt::SmoothTransformation ); coverWithBorders = The::svgHandler()->addBordersToPixmap( coverWithBorders, borderWidth, m_album->text(), true ); } m_albumCover->setPixmap( coverWithBorders ); m_albumCover->graphicsItem()->setAcceptDrops( true ); }
void MainWindow::loadImage() { QString file_name = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath(), "Images(*.png *.jpg *.bmp)"); if ( ! file_name.isEmpty()) { sourceImage = QImage(file_name); if (sourceImage.isNull()) { QMessageBox::information(this, tr("Image Viewer"), tr("Cannot load %1.").arg(file_name)); return; } if (sourceImage.width() > 800) { QPixmap mp = QPixmap::fromImage(sourceImage); mp = mp.scaledToWidth(800, Qt::SmoothTransformation); sourceImage = mp.toImage(); } displayImage(sourceImage); emit imageLoaded(sourceImage); } }