本文整理汇总了C++中QuillImage::save方法的典型用法代码示例。如果您正苦于以下问题:C++ QuillImage::save方法的具体用法?C++ QuillImage::save怎么用?C++ QuillImage::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QuillImage
的用法示例。
在下文中一共展示了QuillImage::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testEdittingHistory
void ut_file::testEdittingHistory()
{
QTemporaryFile testFile1;
testFile1.open();
QuillImage image = Unittests::generatePaletteImage();
image.save(testFile1.fileName(), "png");
QuillImageFilter *filter =
QuillImageFilterFactory::createImageFilter(QuillImageFilter::Name_BrightnessContrast);
QVERIFY(filter);
filter->setOption(QuillImageFilter::Brightness, QVariant(20));
QuillFile *file = new QuillFile(testFile1.fileName(), Strings::png);
File *fileObject = file->internalFile();
QVERIFY(file->setDisplayLevel(0));
QVERIFY(!fileObject->hasOriginal());
QFile editHistory(fileObject->editHistoryFileName(fileObject->fileName(),
Core::instance()->editHistoryPath()));
QVERIFY(!editHistory.exists());
file->runFilter(filter);
file->undo();
QVERIFY(editHistory.exists());
QVERIFY(!fileObject->hasOriginal());
}
示例2: testDropRedoHistory
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;
}
示例3: testCroppedThumbnailAfterEdit
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;
}
示例4: testDifferentPreviewLevels
void ut_file::testDifferentPreviewLevels()
{
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 imageAfter = filter->apply(image);
Quill::setPreviewSize(0, QSize(4, 1));
QuillFile *file = new QuillFile(testFile.fileName(), Strings::png);
QuillFile *file2 = new QuillFile(testFile.fileName(), Strings::png);
QSignalSpy spy(file, SIGNAL(imageAvailable(const QuillImageList)));
QSignalSpy spy2(file2, SIGNAL(imageAvailable(const QuillImageList)));
QVERIFY(file != file2);
QVERIFY(file2->setDisplayLevel(1));
QVERIFY(file->setDisplayLevel(0));
file->runFilter(filter);
Quill::releaseAndWait(); // load level 0
Quill::releaseAndWait(); // brightness level 0
QCOMPARE(spy.count(), 1);
QCOMPARE(spy2.count(), 1);
QCOMPARE(file->image().size(), QSize(4, 1));
QCOMPARE(file->image().z(), 0);
QCOMPARE(file2->image().size(), QSize(4, 1));
QCOMPARE(file2->image().z(), 0);
Quill::releaseAndWait(); // load level 1
Quill::releaseAndWait(); // brightness level 1
QCOMPARE(spy.count(), 1);
QCOMPARE(spy2.count(), 2);
QCOMPARE(file->image().size(), QSize(4, 1));
QCOMPARE(file->image().z(), 0);
QVERIFY(Unittests::compareImage(file2->image(), imageAfter));
QCOMPARE(file2->image().z(), 1);
delete file2;
// Ensure that the display level is kept even if the other image reference
// is removed.
QCOMPARE(file->image().size(), QSize(4, 1));
QCOMPARE(file->image().z(), 0);
delete file;
}
示例5: testDoubleRevertRestore
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;
}
示例6: testOriginalAfterSave
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;
}
示例7: 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;
}
示例8: testMultipleAccess
void ut_file::testMultipleAccess()
{
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 imageAfter = filter->apply(image);
QuillFile *file = new QuillFile(testFile.fileName(), Strings::png);
QuillFile *file2 = new QuillFile(testFile.fileName(), Strings::png);
QVERIFY(file != file2);
QVERIFY(file->setDisplayLevel(0));
QVERIFY(file2->setDisplayLevel(0));
file->runFilter(filter);
Quill::releaseAndWait();
Quill::releaseAndWait();
QVERIFY(Unittests::compareImage(file->image(), imageAfter));
QVERIFY(Unittests::compareImage(file2->image(), imageAfter));
file2->undo();
Quill::releaseAndWait();
QVERIFY(Unittests::compareImage(file->image(), image));
QVERIFY(Unittests::compareImage(file2->image(), image));
delete file2;
file->redo();
Quill::releaseAndWait();
QVERIFY(Unittests::compareImage(file->image(), imageAfter));
delete file;
}
示例9: testSessionSetup
void ut_stack::testSessionSetup()
{
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(filter);
filter->setOption(QuillImageFilter::Contrast, QVariant(20));
QuillFile *file = new QuillFile(testFile.fileName(), Strings::png);
file->runFilter(filter);
file->runFilter(filter2);
file->undo();
QVERIFY(!file->isSession());
QVERIFY(file->canUndo());
QVERIFY(file->canRedo());
file->startSession();
// We are in a session now, cannot undo or redo
QVERIFY(file->isSession());
QVERIFY(!file->canUndo());
QVERIFY(!file->canRedo());
// If we end the session now, we should still be able to undo and redo
file->endSession();
QVERIFY(!file->isSession());
QVERIFY(file->canUndo());
QVERIFY(file->canRedo());
delete file;
}
示例10: testSaveAfterDelete
void ut_file::testSaveAfterDelete()
{
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 imageAfter = filter->apply(image);
QuillFile *file = new QuillFile(testFile.fileName(), Strings::png);
file->runFilter(filter);
QVERIFY(!Quill::isSaveInProgress());
QVERIFY(!file->isSaveInProgress());
file->save();
QVERIFY(Quill::isSaveInProgress());
QVERIFY(file->isSaveInProgress());
delete file;
QVERIFY(Quill::isSaveInProgress());
Quill::releaseAndWait(); // load
QVERIFY(Quill::isSaveInProgress());
Quill::releaseAndWait(); // b/c
QVERIFY(Quill::isSaveInProgress());
Quill::releaseAndWait(); // save
QVERIFY(!Quill::isSaveInProgress());
Unittests::compareImage(QImage(testFile.fileName()), imageAfter);
}
示例11: testOriginal
void ut_file::testOriginal()
{
QTemporaryFile testFile;
testFile.open();
QuillImage image = Unittests::generatePaletteImage();
image.save(testFile.fileName(), "png");
QuillFile *file = new QuillFile(testFile.fileName(), Strings::png);
QuillImageFilter *filter =
QuillImageFilterFactory::createImageFilter(QuillImageFilter::Name_BrightnessContrast);
QVERIFY(filter);
filter->setOption(QuillImageFilter::Brightness, QVariant(20));
QuillImage processedImage = filter->apply(image);
file->runFilter(filter);
QuillFile *original = file->original();
QCOMPARE(file->fileName(), original->fileName());
QCOMPARE(file->originalFileName(), original->originalFileName());
QVERIFY(file->canUndo());
QVERIFY(!original->canUndo());
file->setDisplayLevel(0);
Quill::releaseAndWait();
Quill::releaseAndWait();
original->setDisplayLevel(0);
Quill::releaseAndWait();
QCOMPARE(file->image(), processedImage);
QCOMPARE(original->image(), image);
file->remove();
QVERIFY(!file->exists());
QVERIFY(!original->exists());
delete file;
delete original;
}
示例12: testReadOnly
void ut_file::testReadOnly()
{
if (Unittests::isRoot()) {
qDebug() << "Running as root, disabling file permissions test!";
return;
}
QTemporaryFile testFile;
testFile.open();
QuillImage image = Unittests::generatePaletteImage();
image.save(testFile.fileName(), "png");
QFile qFile(testFile.fileName());
qFile.setPermissions(QFile::ReadOwner);
QuillFile *file = new QuillFile(testFile.fileName(), Strings::png);
QVERIFY(!file->supportsEditing());
delete file;
}
示例13: testUndoRedoDuringSessionRecording
void ut_stack::testUndoRedoDuringSessionRecording()
{
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(filter);
filter->setOption(QuillImageFilter::Contrast, QVariant(20));
QuillFile *file = new QuillFile(testFile.fileName(), Strings::png);
file->startSession();
file->runFilter(filter);
file->runFilter(filter2);
file->undo();
// Between commands, we should still be able to undo
QVERIFY(file->canUndo());
file->undo();
QVERIFY(file->canRedo());
// Between commands, we should still be able to redo
file->redo();
QVERIFY(file->canRedo());
delete file;
}
示例14: testSessionSaveLoad
void ut_stack::testSessionSaveLoad()
{
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);
QuillImageFilter *filter3 =
QuillImageFilterFactory::createImageFilter(QuillImageFilter::Name_Flip);
QVERIFY(filter);
QuillImage resultImage3 = filter3->apply(resultImage2);
QuillImageFilter *filter4 =
QuillImageFilterFactory::createImageFilter(QuillImageFilter::Name_Rotate);
QVERIFY(filter);
filter4->setOption(QuillImageFilter::Angle, QVariant(90));
QuillImage resultImage4 = filter4->apply(resultImage3);
Quill::setEditHistoryPath("/tmp/quill/history");
Quill::setEditHistoryCacheSize(0, 5);
QuillFile *file = new QuillFile(testFile.fileName(), Strings::png);
file->startSession();
file->runFilter(filter);
file->runFilter(filter2);
file->endSession();
file->startSession();
file->runFilter(filter3);
file->runFilter(filter4);
file->endSession();
file->undo();
file->save();
Quill::releaseAndWait(); // load
Quill::releaseAndWait(); // filter1
Quill::releaseAndWait(); // filter2
Quill::releaseAndWait(); // save
QVERIFY(Unittests::compareImage(QImage(testFile.fileName()), resultImage2));
Quill::cleanup();
Quill::initTestingMode();
Quill::setPreviewSize(0, QSize(8, 2));
Quill::setEditHistoryPath("/tmp/quill/history");
Quill::setEditHistoryCacheSize(0, 5);
QuillFile *file2 = new QuillFile(testFile.fileName(), Strings::png);
file2->setDisplayLevel(0);
Quill::releaseAndWait(); // load
QVERIFY(Unittests::compareImage(file2->image(), resultImage2));
file2->redo();
Quill::releaseAndWait(); // load
Quill::releaseAndWait(); // filter3
Quill::releaseAndWait(); // filter4
QVERIFY(Unittests::compareImage(file2->image(), resultImage4));
file2->undo();
QVERIFY(Unittests::compareImage(file2->image(), resultImage2));
file2->undo();
Quill::releaseAndWait(); // load
QVERIFY(Unittests::compareImage(file2->image(), image));
delete file;
delete file2;
}
示例15: testSessionUndoRedo
void ut_stack::testSessionUndoRedo()
{
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);
QuillImageFilter *filter3 =
QuillImageFilterFactory::createImageFilter(QuillImageFilter::Name_Flip);
QVERIFY(filter);
QuillImage resultImage3 = filter3->apply(resultImage2);
QuillImageFilter *filter4 =
QuillImageFilterFactory::createImageFilter(QuillImageFilter::Name_Rotate);
QVERIFY(filter);
filter4->setOption(QuillImageFilter::Angle, QVariant(90));
QuillImage resultImage4 = filter4->apply(resultImage3);
Quill::setEditHistoryCacheSize(0, 5);
QuillFile *file = new QuillFile(testFile.fileName(), Strings::png);
file->runFilter(filter);
file->startSession();
file->runFilter(filter2);
// Inside a session, we should be able to undo
QVERIFY(file->canUndo());
QVERIFY(!file->canRedo());
file->runFilter(filter3);
file->endSession();
// Should still be able to undo
QVERIFY(file->canUndo());
file->runFilter(filter4);
// Get up to date
file->setDisplayLevel(0);
Quill::releaseAndWait();
Quill::releaseAndWait();
Quill::releaseAndWait();
Quill::releaseAndWait();
Quill::releaseAndWait();
QVERIFY(Unittests::compareImage(file->image(), resultImage4));
// Undo - single command
file->undo();
QVERIFY(Unittests::compareImage(file->image(), resultImage3));
// Undo - session command
file->undo();
QVERIFY(Unittests::compareImage(file->image(), resultImage));
QVERIFY(file->canUndo());
QVERIFY(file->canRedo());
// Redo - session command
file->redo();
QVERIFY(Unittests::compareImage(file->image(), resultImage3));
delete file;
}