本文整理汇总了C++中DImg::convertToPixmap方法的典型用法代码示例。如果您正苦于以下问题:C++ DImg::convertToPixmap方法的具体用法?C++ DImg::convertToPixmap怎么用?C++ DImg::convertToPixmap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DImg
的用法示例。
在下文中一共展示了DImg::convertToPixmap方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paint
void ImagePreviewItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
Q_D(GraphicsDImgItem);
QRect drawRect = option->exposedRect.intersected(boundingRect()).toAlignedRect();
QRect pixSourceRect;
QPixmap pix;
QSize completeSize = boundingRect().size().toSize();
/* For high resolution ("retina") displays, Mac OS X / Qt
report only half of the physical resolution in terms of
pixels, i.e. every logical pixels corresponds to 2x2
physical pixels. However, UI elements and fonts are
nevertheless rendered at full resolution, and pixmaps
as well, provided their resolution is high enough (that
is, higher than the reported, logical resolution).
To work around this, we render the photos not a logical
resolution, but with the photo's full resolution, but
at the screen's aspect ratio. When we later draw this
high resolution bitmap, it is up to Qt to scale the
photo to the true physical resolution. The ratio
computed below is the ratio between the photo and
screen resolutions, or equivalently the factor by which
we need to increase the pixel size of the rendered
pixmap.
*/
#ifdef USE_QT_SCALING
double xratio = double(d->image.width()) / completeSize.width();
double yratio = double(d->image.height()) / completeSize.height();
double ratio = qMax(qMin(xratio, yratio), 1.0);
#else
double ratio = 1.0;
#endif
QRect scaledDrawRect = QRectF(ratio*drawRect.x(), ratio*drawRect.y(),
ratio*drawRect.width(), ratio*drawRect.height()).toRect();
// scale "as if" scaling to whole image, but clip output to our exposed region
QSize scaledCompleteSize = QSizeF(ratio*completeSize.width(), ratio*completeSize.height()).toSize();
DImg scaledImage = d->image.smoothScaleClipped(scaledCompleteSize.width(), scaledCompleteSize.height(),
scaledDrawRect.x(), scaledDrawRect.y(),
scaledDrawRect.width(), scaledDrawRect.height());
if (d->cachedPixmaps.find(scaledDrawRect, &pix, &pixSourceRect))
{
if (pixSourceRect.isNull())
{
painter->drawPixmap(drawRect, pix);
}
else
{
painter->drawPixmap(drawRect, pix, pixSourceRect);
}
}
else
{
// TODO: factoring ICC settings code using ImageIface/EditorCore methods.
// Apply CM settings.
bool doSoftProofing = EditorCore::defaultInstance()->softProofingEnabled();
ICCSettingsContainer iccSettings = EditorCore::defaultInstance()->getICCSettings();
if (iccSettings.enableCM && (iccSettings.useManagedView || doSoftProofing))
{
IccManager manager(scaledImage);
IccTransform monitorICCtrans;
if (doSoftProofing)
{
monitorICCtrans = manager.displaySoftProofingTransform(iccSettings.defaultProofProfile, widget);
}
else
{
monitorICCtrans = manager.displayTransform(widget);
}
pix = scaledImage.convertToPixmap(monitorICCtrans);
}
else
{
pix = scaledImage.convertToPixmap();
}
d->cachedPixmaps.insert(scaledDrawRect, pix);
painter->drawPixmap(drawRect, pix);
}
// Show the Over/Under exposure pixels indicators
ExposureSettingsContainer* const expoSettings = EditorCore::defaultInstance()->getExposureSettings();
if (expoSettings)
{
if (expoSettings->underExposureIndicator || expoSettings->overExposureIndicator)
{
QImage pureColorMask = scaledImage.pureColorMask(expoSettings);
QPixmap pixMask = QPixmap::fromImage(pureColorMask);
//.........这里部分代码省略.........
示例2: composeImage
//.........这里部分代码省略.........
DColor transparent(backgroundColor);
transparent.setAlpha(d->transparency);
if (image->sixteenBit())
{
transparent.convertToSixteenBit();
}
transparentLayer.fill(transparent);
textArea.bitBlendImage(composer, &transparentLayer, 0, 0, transparentLayer.width(), transparentLayer.height(),
textAreaBackgroundRect.x(), textAreaBackgroundRect.y());
}
DImg textNotDrawn;
if (textArea.sixteenBit())
{
textNotDrawn = textArea.copy();
textNotDrawn.convertToEightBit();
}
else
{
textNotDrawn = textArea;
}
// We have no direct pixel access to font rendering, so now we need to use Qt/X11 for the drawing
// convert text area to pixmap
QPixmap pixmap;
if (destPainter)
{
// We working on tool preview, deal with CM as well
pixmap = d->iface->convertToPixmap(textNotDrawn);
}
else
{
// We working on target image. Do no apply double CM adjustment here.
pixmap = textNotDrawn.convertToPixmap();
}
int fontScaleWidth = qRound(fontWidth / fontScale);
int fontScaleHeight = qRound(fontHeight / fontScale);
QPixmap textPixmap(fontScaleWidth, fontScaleHeight);
textPixmap.fill(Qt::transparent);
QPainter tp(&textPixmap);
tp.setOpacity((qreal)textOpacity / 100.0);
tp.setPen(QPen(textColor, 1));
tp.setFont(font);
switch (textRotation)
{
case ROTATION_NONE:
tp.drawText(0, 0, fontScaleWidth, fontScaleHeight,
alignMode, textString);
break;
case ROTATION_90:
tp.translate(fontScaleWidth, 0);
tp.rotate(90.0);
tp.drawText(0, 0, fontScaleHeight, fontScaleWidth,
alignMode, textString);
break;
case ROTATION_180:
tp.translate(fontScaleWidth, fontScaleHeight);
示例3: paint
void ImageRegionItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
Q_D(GraphicsDImgItem);
d_ptr->drawRect = option->exposedRect.intersected(boundingRect()).toAlignedRect();
QRect pixSourceRect;
QPixmap pix;
QSize completeSize = boundingRect().size().toSize();
// scale "as if" scaling to whole image, but clip output to our exposed region
DImg scaledImage = d->image.smoothScaleClipped(completeSize.width(), completeSize.height(),
d_ptr->drawRect.x(), d_ptr->drawRect.y(),
d_ptr->drawRect.width(), d_ptr->drawRect.height());
if (d->cachedPixmaps.find(d_ptr->drawRect, &pix, &pixSourceRect))
{
if (pixSourceRect.isNull())
{
painter->drawPixmap(d_ptr->drawRect.topLeft(), pix);
}
else
{
painter->drawPixmap(d_ptr->drawRect.topLeft(), pix, pixSourceRect);
}
}
else
{
// TODO: factoring ICC settings code using ImageIface/EditorCore methods.
// Apply CM settings.
bool doSoftProofing = EditorCore::defaultInstance()->softProofingEnabled();
ICCSettingsContainer iccSettings = EditorCore::defaultInstance()->getICCSettings();
if (iccSettings.enableCM && (iccSettings.useManagedView || doSoftProofing))
{
IccManager manager(scaledImage);
IccTransform monitorICCtrans;
if (doSoftProofing)
{
monitorICCtrans = manager.displaySoftProofingTransform(iccSettings.defaultProofProfile, widget);
}
else
{
monitorICCtrans = manager.displayTransform(widget);
}
pix = scaledImage.convertToPixmap(monitorICCtrans);
}
else
{
pix = scaledImage.convertToPixmap();
}
d->cachedPixmaps.insert(d_ptr->drawRect, pix);
painter->drawPixmap(d_ptr->drawRect.topLeft(), pix);
}
paintExtraData(painter);
// Show the Over/Under exposure pixels indicators
ExposureSettingsContainer* const expoSettings = EditorCore::defaultInstance()->getExposureSettings();
if (expoSettings)
{
if (expoSettings->underExposureIndicator || expoSettings->overExposureIndicator)
{
QImage pureColorMask = scaledImage.pureColorMask(expoSettings);
QPixmap pixMask = QPixmap::fromImage(pureColorMask);
painter->drawPixmap(d_ptr->drawRect.topLeft(), pixMask);
}
}
}
示例4: createPreviews
QLayout* ColorCorrectionDlg::createPreviews() const
{
QGridLayout* const grid = new QGridLayout;
QLabel* const originalTitle = new QLabel;
if (d->mode == ProfileMismatch)
{
originalTitle->setText(i18n("Original Colors:"));
}
else if (d->mode == MissingProfile)
{
originalTitle->setText(i18n("Uncorrected Colors:"));
}
else if (d->mode == UncalibratedColor)
{
originalTitle->setText(i18n("Raw Colors:"));
}
originalTitle->setWordWrap(true);
QLabel* const previewOriginal = new QLabel;
DImg copyOriginal = d->preview.copy();
IccManager manager(copyOriginal);
manager.transformForDisplay();
previewOriginal->setPixmap(copyOriginal.convertToPixmap());
QLabel* const targetTitle = new QLabel;
if (d->mode == ProfileMismatch)
{
targetTitle->setText(i18n("Resulting Colors:"));
}
else if (d->mode == MissingProfile)
{
targetTitle->setText(i18n("Correction Applied:"));
}
else if (d->mode == UncalibratedColor)
{
targetTitle->setText(i18n("Corrected Colors:"));
}
targetTitle->setWordWrap(true);
d->previewTarget = new QLabel;
if (d->preview.width() > d->preview.height())
{
grid->addWidget(originalTitle, 0, 0, Qt::AlignTop);
grid->addWidget(previewOriginal, 1, 0);
grid->addWidget(targetTitle, 2, 0, Qt::AlignTop);
grid->addWidget(d->previewTarget, 3, 0);
}
else
{
grid->addWidget(originalTitle, 0, 0, Qt::AlignTop);
grid->addWidget(previewOriginal, 1, 0);
grid->addWidget(targetTitle, 0, 1, Qt::AlignTop);
grid->addWidget(d->previewTarget, 1, 1);
}
return grid;
}