本文整理汇总了C++中DImg::convertToEightBit方法的典型用法代码示例。如果您正苦于以下问题:C++ DImg::convertToEightBit方法的具体用法?C++ DImg::convertToEightBit怎么用?C++ DImg::convertToEightBit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DImg
的用法示例。
在下文中一共展示了DImg::convertToEightBit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apply
void DImgBuiltinFilter::apply(DImg& image) const
{
switch (m_type)
{
case NoOperation:
break;
case Rotate90:
image.rotate(DImg::ROT90);
break;
case Rotate180:
image.rotate(DImg::ROT180);
break;
case Rotate270:
image.rotate(DImg::ROT270);
break;
case FlipHorizontally:
image.flip(DImg::HORIZONTAL);
break;
case FlipVertically:
image.flip(DImg::VERTICAL);
break;
case Crop:
image.crop(m_arg.toRect());
break;
case Resize:
{
QSize s = m_arg.toSize();
image.resize(s.width(), s.height());
break;
}
case ConvertTo8Bit:
image.convertToEightBit();
break;
case ConvertTo16Bit:
image.convertToSixteenBit();
break;
}
}
示例2: composeImage
//.........这里部分代码省略.........
// cut out the text area
DImg textArea = image->copy(drawRect);
if (textArea.isNull())
{
return QRect();
}
// compose semi-transparent background over textArea
DColorComposer* composer = DColorComposer::getComposer(DColorComposer::PorterDuffNone);
if (transparentBackground)
{
DImg transparentLayer(textAreaBackgroundRect.width(), textAreaBackgroundRect.height(), textArea.sixteenBit(), true);
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);