本文整理汇总了C++中QuillImage::setArea方法的典型用法代码示例。如果您正苦于以下问题:C++ QuillImage::setArea方法的具体用法?C++ QuillImage::setArea怎么用?C++ QuillImage::setArea使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QuillImage
的用法示例。
在下文中一共展示了QuillImage::setArea方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testLoadSameFilterTwice
void ut_load::testLoadSameFilterTwice()
{
QTemporaryFile testFile;
testFile.open();
QImage greenTestImage("/usr/share/quillimagefilter-tests/images/854x480_blue.png");
// Verify whether image exists
QVERIFY(!greenTestImage.isNull());
greenTestImage.save(testFile.fileName(), "jpg");
QuillImage target = QuillImage();
target.setFullImageSize(QSize(854, 480));
target.setArea(QRect(0, 0, 854, 480));
QuillImage target2 = QuillImage();
target2.setFullImageSize(QSize(854, 480));
target2.setArea(QRect(0, 0, 854, 480));
QuillImageFilter *filter =
QuillImageFilterFactory::createImageFilter("org.maemo.load");
filter->setOption(QuillImageFilter::FileName, testFile.fileName());
// Passing JPEG through the filter
QuillImage imageAfter = filter->apply(target);
// Passing JPEG through the filter
QuillImage imageAfter2 = filter->apply(target2);
// Checking the red channel value which should be always bigger than that of greeen channel
QVERIFY( qBlue(imageAfter.pixel(QPoint(0, 0))) > qGreen(imageAfter.pixel(QPoint(0, 0))) );
// Checking the red channel value which should be always bigger than that of greeen channel
QVERIFY( qBlue(imageAfter2.pixel(QPoint(0, 0))) > qGreen(imageAfter2.pixel(QPoint(0, 0))) );
delete filter;
}
示例2: testScalePreview
void ut_scale::testScalePreview()
{
// No changes must be made to a preview image
QuillImageFilter *filter =
QuillImageFilterFactory::createImageFilter("org.maemo.scale");
QVERIFY(filter);
QVERIFY(filter->setOption(QuillImageFilter::SizeAfter, QSize(4, 1)));
QuillImage image = Unittests::generatePaletteImage();
QCOMPARE(image.size(), QSize(8, 2));
image.setFullImageSize(QSize(16, 4));
image.setArea(QRect(0, 0, 16, 4));
QuillImage image2 = filter->apply(image);
QCOMPARE(image2.size(), QSize(8, 2));
QCOMPARE(image2.fullImageSize(), QSize(4, 1));
QCOMPARE(image2.area(), QRect(0, 0, 4, 1));
QVERIFY(Unittests::compareImage(image, image2));
delete filter;
}
示例3: testCropping
void ut_load::testCropping()
{
QuillImageFilter *filter =
QuillImageFilterFactory::createImageFilter("org.maemo.load");
QFile file("/usr/share/quillimagefilter-tests/images/16_color_palette.png");
filter->setOption(QuillImageFilter::FileName, QString(file.fileName()));
QuillImage target = QuillImage();
target.setTargetSize(QSize(1, 1));
target.setFullImageSize(QSize(8, 2));
target.setArea(QRect(2, 0, 2, 2));
QuillImage result = filter->apply(target);
QCOMPARE(result.size(), QSize(1, 1));
// Expect an average of the given area (png = smooth scaling).
QCOMPARE(qRed(result.pixel(QPoint(0,0))), 96);
QCOMPARE(qGreen(result.pixel(QPoint(0,0))), 193);
QCOMPARE(qBlue(result.pixel(QPoint(0,0))), 0);
delete filter;
}
示例4: apply
QuillImage LoadFilter::apply(const QuillImage &tile) const
{
if (priv->fileFormatQt.isEmpty() && !priv->isInvalid)
const_cast<LoadFilter *>(this)->detectFormat();
if (priv->isInvalid)
return QuillImage();
bool isNew = !reader
|| (filterAddress != this)
|| !priv->bufferInitialized
|| !tile.isFragment()
|| (priv->fileFormatQt != reader->format())
|| (!tile.targetSize().isEmpty()
&& (tile.targetSize() != tile.area().size()));
filterAddress = const_cast<LoadFilter*>(this);
priv->bufferInitialized = true;
if (priv->iODevice) {
delete reader;
reader = new QImageReader(priv->iODevice, priv->fileFormatQt.toAscii());
if (!priv->fileFormatQt.isEmpty())
reader->setFormat(priv->fileFormatQt.toAscii());
}
else {
if (isNew) {
delete reader;
reader = 0;
if (!const_cast<LoadFilter*>(this)->readFileToByteArray())
return QuillImage();
buffer.seek(0);
priv->orientation = readOrientation();
reader = new QImageReader(&buffer, priv->fileFormatQt.toAscii());
if (!priv->fileFormatQt.isEmpty())
reader->setFormat(priv->fileFormatQt.toAscii());
}
else {
buffer.seek(0);
}
}
QuillImage input = tile;
if (input.fullImageSize().isEmpty())
input.setFullImageSize(reader->size());
if (input.area().isEmpty())
input.setArea(QRect(QPoint(0, 0), input.fullImageSize()));
QImage newImage;
QSize targetSize = input.targetSize();
QSize fullImageSize = input.fullImageSize();
QRect area = rotateArea(fullImageSize, input.area(), input);
if ((priv->orientation == Exif_Orientation_Rotated90) ||
(priv->orientation == Exif_Orientation_Rotated270)) {
targetSize.transpose();
fullImageSize.transpose();
}
/*
Resetting reader for ScaledSize and ClipRect. This resetting
will make sure that the reader will have all the options set
correctly if the same reader has been used previously.
Does not do the calculation in all cases since it is time consuming.
*/
if (reader->scaledSize().isValid() || reader->clipRect().isValid()) {
QSize readerSize = reader->size();
reader->setScaledSize(readerSize);
reader->setClipRect(QRect(QPoint(0,0),readerSize));
}
if (!input.isFragment()){
fullImage = QImage();
if (!targetSize.isEmpty()) {
reader->setScaledSize(targetSize);
}
newImage = readFromReader();
}
else if (!targetSize.isEmpty() &&
(targetSize != area.size())) {
// Both cropping and scaling have been requested
// Current implementation: ask plugin for the scaled image, then crop
// This can be later optimized with a plugin that effectively
// supports the ScaledClipRect option.
reader->setScaledSize(QSize(targetSize.width() *
fullImageSize.width() /
area.width(),
targetSize.height() *
fullImageSize.height() /
//.........这里部分代码省略.........