本文整理汇总了C++中QuillImage类的典型用法代码示例。如果您正苦于以下问题:C++ QuillImage类的具体用法?C++ QuillImage怎么用?C++ QuillImage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QuillImage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QVERIFY
void ut_file::testDoubleRevertRestore()
{
// Tests that revert and restore still work after a previous revert.
QTemporaryFile testFile;
testFile.open();
QuillImage image = Unittests::generatePaletteImage();
image.save(testFile.fileName(), "png");
QuillImageFilter *filter =
QuillImageFilterFactory::createImageFilter(QuillImageFilter::Name_BrightnessContrast);
QVERIFY(filter);
filter->setOption(QuillImageFilter::Brightness, QVariant(20));
QuillImageFilter *filter2 =
QuillImageFilterFactory::createImageFilter(QuillImageFilter::Name_BrightnessContrast);
QVERIFY(filter2);
filter2->setOption(QuillImageFilter::Brightness, QVariant(-20));
QuillFile *file = new QuillFile(testFile.fileName(), Strings::png);
file->runFilter(filter);
QVERIFY(file->canRevert());
file->revert();
QVERIFY(file->canRestore());
file->runFilter(filter2);
QVERIFY(file->canRevert());
file->revert();
QVERIFY(file->canRestore());
delete file;
}
示例2: QuillFile
void ut_file::testOriginalAfterSave()
{
QTemporaryFile testFile;
testFile.open();
QuillImage image = Unittests::generatePaletteImage();
image.save(testFile.fileName(), "png");
QuillFile *file = new QuillFile(testFile.fileName(), Strings::png);
QuillFile *original = file->original();
// This makes us to setup the original's undo stack
QCOMPARE(original->fullImageSize(), image.size());
QuillImageFilter *filter =
QuillImageFilterFactory::createImageFilter(QuillImageFilter::Name_BrightnessContrast);
QVERIFY(filter);
filter->setOption(QuillImageFilter::Brightness, QVariant(20));
QuillImage processedImage = filter->apply(image);
file->runFilter(filter);
file->save();
Quill::releaseAndWait();
Quill::releaseAndWait();
Quill::releaseAndWait();
original->setDisplayLevel(0);
Quill::releaseAndWait();
QVERIFY(Unittests::compareImage(original->image(), image));
delete file;
delete original;
}
示例3: QVERIFY
void ut_rotate::testRotateFilter()
{
QuillImageFilter *filter =
QuillImageFilterFactory::createImageFilter("org.maemo.rotate");
QVERIFY(filter);
QVERIFY(filter->supportsOption(QuillImageFilter::Angle));
QVERIFY(filter->setOption(QuillImageFilter::Angle, QVariant(90)));
bool bOK = true;
QCOMPARE(filter->option(QuillImageFilter::Angle).toDouble(&bOK), 90.0);
QVERIFY(bOK);
QuillImage image = Unittests::generatePaletteImage();
QCOMPARE(image.size(), QSize(8, 2));
QuillImage filteredImage = filter->apply(image);
QCOMPARE(filteredImage.size(), QSize(2, 8));
// Get reference image with QImage::transformed()
QuillImage compareToQImage = image.transformed(QTransform().rotate(90));
QCOMPARE(filteredImage, compareToQImage);
// Four rotates should produce the original image
QCOMPARE(filter->apply(filter->apply(filter->apply(filteredImage))),
image);
delete filter;
}
示例4: qRgba
void ut_load::testTransparency()
{
QTemporaryFile testFile;
testFile.open();
QImage image = Unittests::generatePaletteImage();
image = image.convertToFormat(QImage::Format_ARGB32);
image.setPixel(QPoint(0, 0), qRgba(255, 0, 0, 0));
image.setPixel(QPoint(0, 1), qRgba(255, 0, 0, 127));
image.save(testFile.fileName(), "png");
QuillImageFilter *filter =
QuillImageFilterFactory::createImageFilter("org.maemo.load");
filter->setOption(QuillImageFilter::FileName, testFile.fileName());
filter->setOption(QuillImageFilter::FileFormat, QString("png"));
filter->setOption(QuillImageFilter::BackgroundColor, QColor(qRgb(0, 0, 255)));
QuillImage imageAfter = filter->apply(image);
QCOMPARE(imageAfter.pixel(QPoint(0, 0)), qRgb(0, 0, 255));
QCOMPARE(imageAfter.pixel(QPoint(0, 1)), qRgb(127, 0, 128));
delete filter;
}
示例5: QSize
void ut_croppedthumbnail::testCroppedThumbnailAfterEdit()
{
QTemporaryFile testFile;
testFile.open();
QuillImage image = Unittests::generatePaletteImage();
image.save(testFile.fileName(), "png");
Quill::setPreviewLevelCount(1);
Quill::setPreviewSize(0, QSize(2, 2));
Quill::setMinimumPreviewSize(0, QSize(2, 2));
QuillFile *file = new QuillFile(testFile.fileName());
QuillImageFilter *filter =
QuillImageFilterFactory::createImageFilter(QuillImageFilter::Name_Crop);
filter->setOption(QuillImageFilter::CropRectangle, QRect(0, 0, 4, 2));
file->runFilter(filter);
file->setDisplayLevel(1);
Quill::releaseAndWait(); // load 0
Quill::releaseAndWait(); // crop 0 - bad version
Quill::releaseAndWait(); // load 1
Quill::releaseAndWait(); // crop 1
Quill::releaseAndWait(); // reform 0
file->setDisplayLevel(0);
QCOMPARE(file->allImageLevels().count(), 1);
QCOMPARE(file->allImageLevels().first().size(), QSize(2, 2));
QVERIFY(Unittests::compareImage(file->allImageLevels().first(),
image.copy(1, 0, 2, 2)));
delete file;
}
示例6: QVERIFY
void ut_stack::testDropRedoHistory()
{
QTemporaryFile testFile;
testFile.open();
QuillImage image = Unittests::generatePaletteImage();
image.save(testFile.fileName(), "png");
QuillImageFilter *filter =
QuillImageFilterFactory::createImageFilter(QuillImageFilter::Name_BrightnessContrast);
QVERIFY(filter);
filter->setOption(QuillImageFilter::Brightness, QVariant(20));
QuillImage resultImage = filter->apply(image);
QuillImageFilter *filter2 =
QuillImageFilterFactory::createImageFilter(QuillImageFilter::Name_BrightnessContrast);
QVERIFY(filter);
filter2->setOption(QuillImageFilter::Contrast, QVariant(20));
QuillImage resultImage2 = filter2->apply(resultImage);
QuillFile *file = new QuillFile(testFile.fileName(), Strings::png);
file->runFilter(filter);
file->runFilter(filter2);
file->undo();
QVERIFY(file->canRedo());
file->dropRedoHistory();
QVERIFY(!file->canRedo());
delete file;
}
示例7: QVERIFY
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;
}
示例8: rotateArea
QRect LoadFilter::rotateArea(const QSize &fullImageSize, const QRect &area, const QuillImage &tile) const
{
switch (priv->orientation) {
case Exif_Orientation_Normal:
return area;
case Exif_Orientation_Rotated180:
return QRect(fullImageSize.width()-area.right() - 1,
fullImageSize.height()-area.bottom() - 1,
area.width(), area.height());
case Exif_Orientation_Rotated270:
if(tile.isFragment())
return QRect(fullImageSize.height()-area.bottom()-1,
area.left(),
area.height(), area.width());
else
return QRect(area.top(),
fullImageSize.width()-area.right() - 1,
area.height(), area.width());
case Exif_Orientation_Rotated90:
//The used base image is 3840x2160(WxH), we need to map from 2160x3840(WxH) when we use tiles
if(tile.isFragment())
return QRect(area.top(),
fullImageSize.width()-area.right() - 1,
area.height(), area.width());
//for full screen display from the full image
else
return QRect(fullImageSize.height()-area.bottom() - 1,
area.left(),
area.height(), area.width());
default:
return area;
}
}
示例9: process
bool SerialSaver::process(const QuillImage &image)
{
if (!priv->file) {
errorExit();
return false;
}
uchar *imageData = data(image);
uchar **rows = (uchar**) new int[image.height()];
for (int y=0; y<image.height(); y++)
{
rows[y] = imageData + (image.width() * 3) * y;
}
if (!setjmp(priv->error.setjmp_buffer)) {
int result = jpeg_write_scanlines(&priv->cinfo, rows, image.height());
priv->linesLeft -= image.height();
if (result == 0)
errorExit();
else if (isFinished()) {
jpeg_finish_compress(&priv->cinfo);
jpeg_destroy_compress(&priv->cinfo);
fclose(priv->file);
priv->file = 0;
}
} else
errorExit();
delete[] rows;
delete[] imageData;
return !priv->hasError;
}
示例10: testLastModified
void ut_file::testLastModified()
{
QTemporaryFile testFile;
testFile.open();
QuillImage image = Unittests::generatePaletteImage();
image.save(testFile.fileName(), "png");
QDateTime lastModified = QFileInfo(testFile.fileName()).lastModified();
QuillFile *file = new QuillFile(testFile.fileName(), Strings::png);
QCOMPARE(file->lastModified(), lastModified);
delete file;
}
示例11: QVERIFY
void ut_lanczos::testApply()
{
QVERIFY(filter->setOption(QuillImageFilter::SizeAfter,
QVariant(QSize(16, 16))));
QuillImage image = Unittests::generatePaletteImage();
QCOMPARE(image.size(), QSize(8, 2));
QuillImage filteredImage = filter->apply(image);
// Only verify size, for now
QCOMPARE(filteredImage.size(), QSize(16, 16));
}
示例12: getRadius
double EnlargeShrink::getRadius(const QuillImage &img) const
{
double radius = m_Radius;
if (!img.isFragment() || (img.width() == 170 && img.height() == 170)) {
if (img.fullImageSize().width() < img.fullImageSize().height()) {
radius = radius * img.width() / img.fullImageSize().width();
} else {
radius = radius * img.height() / img.fullImageSize().height();
}
}
return radius;
}
示例13: target
QuillImage LoadFilter::renderAlpha(const QuillImage &image,
const QColor &backgroundColor)
{
QuillImage target(image, QImage(image.size(), QImage::Format_RGB32));
target.fill(backgroundColor.rgb());
QPainter painter(&target);
painter.drawImage(QPoint(0, 0), image);
return target;
}
示例14: QImage
QuillImage EnlargeShrink::apply(const QuillImage& image) const
{
if (image.fullImageSize().isEmpty()) {
return QImage();
}
QuillImage out;
enlargeShrink(image, &out);
return out;
}
示例15: getCenter
QPoint EnlargeShrink::getCenter(const QuillImage &img) const
{
QPoint center = m_Center;
if (!img.isFragment() || (img.width() == 170 && img.height() == 170)) {
center.setX(center.x() * img.width() / img.fullImageSize().width());
center.setY(center.y() * img.height() / img.fullImageSize().height());
}
return center;
}