本文整理汇总了C++中DImg::convertToDepthOfImage方法的典型用法代码示例。如果您正苦于以下问题:C++ DImg::convertToDepthOfImage方法的具体用法?C++ DImg::convertToDepthOfImage怎么用?C++ DImg::convertToDepthOfImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DImg
的用法示例。
在下文中一共展示了DImg::convertToDepthOfImage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toolOperations
//.........这里部分代码省略.........
case Private::Center:
alignMode = Qt::AlignCenter;
break;
default : // BottomRight
alignMode = Qt::AlignRight;
break;
}
font.setPointSizeF(fontSize);
QFontMetrics fontMt(font);
QRect fontRect = fontMt.boundingRect(radius, radius, image().width(), image().height(), 0, text);
// Add a transparent layer.
QRect backgroundRect(fontRect.x() - radius, fontRect.y() - radius,
fontRect.width() + 2 * radius, fontRect.height() + 2 * radius);
DImg backgroundLayer(backgroundRect.width(), backgroundRect.height(), image().sixteenBit(), true);
DColor transparent(QColor(0, 0, 0));
transparent.setAlpha(0);
if (image().sixteenBit())
{
transparent.convertToSixteenBit();
}
backgroundLayer.fill(transparent);
DImg grayTransLayer(fontRect.width(), fontRect.height(), image().sixteenBit(), true);
if (useBackground)
{
DColor grayTrans(backgroundColor);
grayTrans.setAlpha(backgroundOpacity * 255 / 100);
if (image().sixteenBit())
{
grayTrans.convertToSixteenBit();
}
grayTransLayer.fill(grayTrans);
backgroundLayer.bitBlendImage(composer, &grayTransLayer, 0, 0,
grayTransLayer.width(), grayTransLayer.height(),
radius, radius);
}
BlurFilter blur(&backgroundLayer, 0L, radius);
blur.startFilterDirectly();
backgroundLayer.putImageData(blur.getTargetImage().bits());
// Draw text
QImage img = backgroundLayer.copyQImage(fontRect);
QPainter p(&img);
fontColor.setAlpha(textOpacity * 255 / 100);
p.setPen(QPen(fontColor, 1));
p.setFont(font);
p.save();
p.drawText(0, 0, fontRect.width(), fontRect.height(), alignMode, text);
p.restore();
p.end();
watermarkImage = DImg(img);
}
watermarkImage.convertToDepthOfImage(&image());
QRect watermarkRect(0, 0, watermarkImage.width(), watermarkImage.height());
switch (placement)
{
case Private::TopLeft:
watermarkRect.moveTopLeft(QPoint(marginW, marginH));
break;
case Private::TopRight:
watermarkRect.moveTopRight(QPoint(image().width() - marginW, marginH));
break;
case Private::BottomLeft:
watermarkRect.moveBottomLeft(QPoint(marginW, image().height() - marginH));
break;
case Private::Center:
watermarkRect.moveCenter(QPoint((int)(image().width() / 2), (int)(image().height() / 2)));
break;
default : // BottomRight
watermarkRect.moveBottomRight(QPoint(image().width() - marginW, image().height() - marginH));
break;
}
// TODO: Create watermark filter, move code there, implement FilterAction
image().bitBlendImage(composer, &watermarkImage, 0, 0, watermarkImage.width(), watermarkImage.height(),
watermarkRect.left(), watermarkRect.top());
delete composer;
return (savefromDImg());
}