本文整理汇总了C++中DImg::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ DImg::isNull方法的具体用法?C++ DImg::isNull怎么用?C++ DImg::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DImg
的用法示例。
在下文中一共展示了DImg::isNull方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sz
uchar* ImageIface::Private::previewImageData()
{
if (previewImage.isNull())
{
DImg* im = 0;
if (previewType == FullImage)
{
im = core->getImg();
if (!im || im->isNull())
{
return 0;
}
}
else // ImageSelection
{
im = new DImg(core->getImgSelection());
if (!im)
{
return 0;
}
if (im->isNull())
{
delete im;
return 0;
}
im->setIccProfile(core->getEmbeddedICC());
}
QSize sz(im->width(), im->height());
sz.scale(constrainWidth, constrainHeight, Qt::KeepAspectRatio);
previewImage = im->smoothScale(sz.width(), sz.height());
previewWidth = previewImage.width();
previewHeight = previewImage.height();
// only create another copy if needed, in setPreviewImage
targetPreviewImage = previewImage;
if (previewType == ImageSelection)
{
delete im;
}
}
DImg previewData = previewImage.copyImageData();
return previewData.stripImageData();
}
示例2: slotGotImagePreview
void DImgPreviewItem::slotGotImagePreview(const LoadingDescription& description, const DImg& image)
{
Q_D(DImgPreviewItem);
if (description.filePath != d->path || description.isThumbnail())
{
return;
}
setImage(image);
if (image.isNull())
{
d->state = ImageLoadingFailed;
emit stateChanged(d->state);
emit loadingFailed();
}
else
{
d->state = ImageLoaded;
emit stateChanged(d->state);
emit loaded();
}
preloadNext();
}
示例3: run
void ImageQualityTask::run()
{
if (!d->cancel)
{
// Get item preview to perform quality analysis. No need to load whole image, this will be slower.
// TODO : check if 1024 pixels size is enough to get suitable Quality results.
DImg dimg = PreviewLoadThread::loadFastSynchronously(d->path, 1024);
if (!dimg.isNull() && !d->cancel)
{
// TODO : run here Quality analysis backend and store Pick Label result to DB.
// Backend Input : d->quality as Quality analysis settings,
// dimg as reduced size image data to parse,
// d->path as file path to patch DB properties.
// Result : Backend must scan Quality of image depending of settings and compute a Quality estimation accordingly.
// Finaly, using file path, DB Pick Label properties must be assigned through ImageInfo interface.
// Warning : All code here will run in a separated thread and must be re-entrant/thread-safe. Only pure computation
// must be processed. GUI calls are prohibited. ImageInfo and DImg can be used safety in thread.
PickLabel pick;
d->imgqsort = new ImgQSort(dimg, d->quality, &pick);
d->imgqsort->startAnalyse();
ImageInfo info = ImageInfo::fromLocalFile(d->path);
info.setPickLabel(pick);
delete d->imgqsort; //delete image data after setting label
d->imgqsort = 0;
}
// Dispatch progress to Progress Manager
QImage qimg = dimg.smoothScale(22, 22, Qt::KeepAspectRatio).copyQImage();
emit signalFinished(qimg);
emit signalDone();
}
}
示例4: restoreSnapshot
void UndoManager::restoreSnapshot(int index, const UndoMetadataContainer& c)
{
DImg img = d->undoCache->getData(index);
if (!img.isNull())
{
d->core->setUndoImg(c, img);
}
}
示例5: applyBCG
void BCGFilter::applyBCG(DImg& image)
{
if (image.isNull())
{
return;
}
applyBCG(image.bits(), image.width(), image.height(), image.sixteenBit());
}
示例6: setOriginal
void ImageIface::setOriginal(const QString& caller, const FilterAction& action, const DImg& img)
{
if (img.isNull())
{
kDebug() << "No image data to handle";
return;
}
d->core->putImg(caller, action, img);
}
示例7: setSelection
void ImageIface::setSelection(const QString& caller, const FilterAction& action, const DImg& img)
{
if (img.hasAlpha() != originalHasAlpha() ||
img.sixteenBit() != originalSixteenBit() ||
img.size() != selectionRect().size()
)
{
kDebug() << "Properties of image to overwrite selection differs than original image";
return;
}
if (img.isNull())
{
kDebug() << "No image data to handle";
return;
}
d->core->putImgSelection(caller, action, img);
}
示例8: slotGotImagePreview
void FingerPrintsGenerator::slotGotImagePreview(const LoadingDescription& desc, const DImg& img)
{
if (d->allPicturesPath.isEmpty())
{
return;
}
if (d->allPicturesPath.first() != desc.filePath)
{
return;
}
if (!img.isNull())
{
// compute Haar fingerprint
d->haarIface.indexImage(desc.filePath, img);
}
QPixmap pix = DImg(img).smoothScale(128, 128, Qt::KeepAspectRatio).convertToPixmap();
addedAction(pix, desc.filePath);
advance(1);
if (!d->allPicturesPath.isEmpty())
{
d->allPicturesPath.removeFirst();
}
if (d->allPicturesPath.isEmpty())
{
complete();
}
else
{
processOne();
}
}
示例9: applyHSL
void HSLFilter::applyHSL(DImg& image)
{
if (image.isNull())
{
return;
}
bool sixteenBit = image.sixteenBit();
uint numberOfPixels = image.numPixels();
int progress;
int hue, sat, lig;
double vib = d->settings.vibrance;
DColor color;
if (sixteenBit) // 16 bits image.
{
unsigned short* data = (unsigned short*) image.bits();
for (uint i=0; runningFlag() && (i<numberOfPixels); ++i)
{
color = DColor(data[2], data[1], data[0], 0, sixteenBit);
// convert RGB to HSL
color.getHSL(&hue, &sat, &lig);
// convert HSL to RGB
color.setHSL(d->htransfer16[hue], vibranceBias(d->stransfer16[sat], hue, vib, sixteenBit), d->ltransfer16[lig], sixteenBit);
data[2] = color.red();
data[1] = color.green();
data[0] = color.blue();
data += 4;
progress = (int)(((double)i * 100.0) / numberOfPixels);
if ( progress%5 == 0 )
{
postProgress( progress );
}
}
}
else // 8 bits image.
{
uchar* data = image.bits();
for (uint i=0; runningFlag() && (i<numberOfPixels); ++i)
{
color = DColor(data[2], data[1], data[0], 0, sixteenBit);
// convert RGB to HSL
color.getHSL(&hue, &sat, &lig);
// convert HSL to RGB
color.setHSL(d->htransfer[hue], vibranceBias(d->stransfer[sat],hue,vib,sixteenBit), d->ltransfer[lig], sixteenBit);
data[2] = color.red();
data[1] = color.green();
data[0] = color.blue();
data += 4;
progress = (int)(((double)i * 100.0) / numberOfPixels);
if ( progress%5 == 0 )
{
postProgress( progress );
}
}
}
}
示例10: composeImage
//.........这里部分代码省略.........
// emergency fallback - nothing is visible
x = qMax( (maxWidth - boxWidth) / 2, 0);
y = qMax( (maxHeight - boxHeight) / 2, 0);
}
// invalidate position hint, use only once
d->positionHint = QRect();
}
else
{
// use standard position
x = qMax( (maxWidth - boxWidth) / 2, 0);
y = qMax( (maxHeight - boxHeight) / 2, 0);
}
}
// create a rectangle relative to image
QRect drawRect( x, y, fontWidth + 2 * borderWidth + 2 * spacing, fontHeight + 2 * borderWidth + 2 * spacing);
// create a rectangle relative to textArea, excluding the border
QRect textAreaBackgroundRect( borderWidth, borderWidth, fontWidth + 2 * spacing, fontHeight + 2 * spacing);
// create a rectangle relative to textArea, excluding the border and spacing
QRect textAreaTextRect( borderWidth + spacing, borderWidth + spacing, fontWidth, fontHeight );
// create a rectangle relative to textArea, including the border,
// for drawing the rectangle, taking into account that the width of the QPen goes in and out in equal parts
QRect textAreaDrawRect( borderWidth / 2, borderWidth / 2, fontWidth + borderWidth + 2 * spacing,
fontHeight + borderWidth + 2 * spacing );
// 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
{
示例11: toolOperations
bool WaterMark::toolOperations()
{
if (!loadToDImg())
{
return false;
}
QString fileName = settings()[QLatin1String("Watermark image")].toString();
int placement = settings()[QLatin1String("Placement")].toInt();
int size = settings()[QLatin1String("Watermark size")].toInt();
int xMargin = settings()[QLatin1String("X margin")].toInt();
int yMargin = settings()[QLatin1String("Y margin")].toInt();
bool useImage = settings()[QLatin1String("Use image")].toBool();
QString text = settings()[QLatin1String("Text")].toString();
QFont font = settings()[QLatin1String("Font")].toString();
QColor fontColor = settings()[QLatin1String("Color")].toString();
int textOpacity = settings()[QLatin1String("Text opacity")].toInt();
bool useBackground = settings()[QLatin1String("Use background")].toBool();
QColor backgroundColor = settings()[QLatin1String("Background color")].toString();
int backgroundOpacity = settings()[QLatin1String("Background opacity")].toInt();
DImg watermarkImage;
DColorComposer* composer = DColorComposer::getComposer(DColorComposer::PorterDuffNone);
int marginW = lround(image().width() * (xMargin / 100.0));
int marginH = lround(image().height() * (yMargin / 100.0));
if (useImage)
{
watermarkImage = DImg(fileName);
if (watermarkImage.isNull())
{
return false;
}
DImg tempImage = watermarkImage.smoothScale(image().width() * size / 100, image().height() * size / 100, Qt::KeepAspectRatio);
watermarkImage = tempImage;
}
else
{
int alignMode;
const int radius = 10;
if (text.isEmpty())
{
return false;
}
int fontSize = queryFontSize(text, font, size);
if (fontSize == 0)
{
return false;
}
switch (placement)
{
case Private::TopLeft:
alignMode = Qt::AlignLeft;
break;
case Private::TopRight:
alignMode = Qt::AlignRight;
break;
case Private::BottomLeft:
alignMode = Qt::AlignLeft;
break;
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);
//.........这里部分代码省略.........