SVN commit 866900 by cgilles:
kipi-plugins from trunk : DNGConverter: add new option to embed original RAW file as compressed ZIP data as it's described into DNG spec. CCMAIL: [hidden email] CCMAIL: [hidden email] M +47 -17 dngwriter/dngwriter.cpp M +3 -0 dngwriter/dngwriter.h M +1 -0 dngwriter/dngwriterprivate.cpp M +1 -0 dngwriter/dngwriterprivate.h M +11 -3 plugin/actionthread.cpp M +1 -0 plugin/actionthread.h M +6 -3 plugin/batchdialog.cpp M +31 -15 plugin/settingswidget.cpp M +3 -0 plugin/settingswidget.h --- trunk/extragear/graphics/kipi-plugins/dngconverter/dngwriter/dngwriter.cpp #866899:866900 @@ -52,6 +52,7 @@ // KDE includes. #include <kdebug.h> +#include <kzip.h> // Libkexiv2 includes. @@ -98,6 +99,16 @@ return d->jpegLossLessCompression; } +void DNGWriter::setBackupOriginalRawFile(bool b) +{ + d->backupOriginalRawFile = b; +} + +bool DNGWriter::backupOriginalRawFile() const +{ + return d->backupOriginalRawFile; +} + void DNGWriter::setPreviewMode(int mode) { d->previewMode = mode; @@ -630,33 +641,51 @@ negative->SetMakerNoteSafety(true); } -/* FIXME: embeding original RAW file data do not work yet + if (d->backupOriginalRawFile) { kDebug( 51000 ) << "DNGWriter: Backup Original RAW file (" << inputInfo.size() << " bytes)" << endl; - QFile file(inputFile()); - if ( !file.open(QIODevice::ReadOnly) ) + // Compress Raw file data to Zip archive. + + QTemporaryFile zipFile; + if (!zipFile.open()) { - kDebug( 51000 ) << "DNGWriter: Loading RAW data failed. Aborted..." << endl; + kDebug( 51000 ) << "DNGWriter: Cannot open temporary file to write Zip Raw file. Aborted..." << endl; return -1; } - QByteArray orgRawFile; - orgRawFile.resize(inputInfo.size()); - QDataStream dataStream(&file); - dataStream.readRawData(orgRawFile.data(), orgRawFile.size()); - file.close(); + KZip zipArchive(zipFile.fileName()); + zipArchive.open(QIODevice::WriteOnly); + zipArchive.setCompression(KZip::DeflateCompression); + zipArchive.addLocalFile(inputFile(), inputFile()); + zipArchive.close(); - QByteArray zCompressData = qCompress(orgRawFile, 9); + // Load Zip Archive in a byte array + + QFileInfo zipFileInfo(zipFile.fileName()); + QByteArray zipRawFileData; + zipRawFileData.resize(zipFileInfo.size()); + QDataStream dataStream(&zipFile); + dataStream.readRawData(zipRawFileData.data(), zipRawFileData.size()); + kDebug( 51000 ) << "DNGWriter: Zipped RAW file size " << zipRawFileData.size() << " bytes" << endl; + + // Pass byte array to DNG sdk and compute MD5 fingerprint. + dng_memory_allocator memalloc(gDefaultDNGMemoryAllocator); dng_memory_stream stream(memalloc); - stream.Put(zCompressData.data(), zCompressData.size()); - AutoPtr<dng_memory_block> block(host.Allocate(zCompressData.size())); + stream.Put(zipRawFileData.data(), zipRawFileData.size()); + AutoPtr<dng_memory_block> block(host.Allocate(zipRawFileData.size())); stream.SetReadPosition(0); - stream.Get(block->Buffer(), zCompressData.size()); + stream.Get(block->Buffer(), zipRawFileData.size()); + + dng_md5_printer md5; + md5.Process(block->Buffer(), block->LogicalSize()); negative->SetOriginalRawFileData(block); - negative->SetHasOriginalRawFileData(true); + negative->SetOriginalRawFileDigest(md5.Result()); + negative->ValidateOriginalRawFileDigest(); + + zipFile.remove(); } -*/ + if (d->cancel) return -2; // ----------------------------------------------------------------------------------------- @@ -681,7 +710,7 @@ dng_preview_list previewList; - // NOTE: something is wrong with Qt < 4.4.0 to import TIFF data as stream in QImage. +// NOTE: something is wrong with Qt < 4.4.0 to import TIFF data as stream in QImage. #if QT_VERSION >= 0x40400 if (d->previewMode != DNGWriter::NONE) @@ -744,8 +773,9 @@ previewFile.remove(); } -#endif +#endif /* QT_VERSION >= 0x40400 */ + if (d->cancel) return -2; // ----------------------------------------------------------------------------------------- --- trunk/extragear/graphics/kipi-plugins/dngconverter/dngwriter/dngwriter.h #866899:866900 @@ -58,6 +58,9 @@ void setCompressLossLess(bool b); bool compressLossLess() const; + void setBackupOriginalRawFile(bool b); + bool backupOriginalRawFile() const; + void setPreviewMode(int mode); int previewMode() const; --- trunk/extragear/graphics/kipi-plugins/dngconverter/dngwriter/dngwriterprivate.cpp #866899:866900 @@ -53,6 +53,7 @@ { cancel = false; jpegLossLessCompression = true; + backupOriginalRawFile = false; previewMode = DNGWriter::MEDIUM; } --- trunk/extragear/graphics/kipi-plugins/dngconverter/dngwriter/dngwriterprivate.h #866899:866900 @@ -74,6 +74,7 @@ bool cancel; bool jpegLossLessCompression; + bool backupOriginalRawFile; int previewMode; --- trunk/extragear/graphics/kipi-plugins/dngconverter/plugin/actionthread.cpp #866899:866900 @@ -58,9 +58,10 @@ ActionThreadPriv() { - compressLossLess = true; - running = false; - previewMode = DNGWriter::MEDIUM; + backupOriginalRawFile = false; + compressLossLess = true; + running = false; + previewMode = DNGWriter::MEDIUM; } class Task @@ -71,6 +72,7 @@ Action action; }; + bool backupOriginalRawFile; bool compressLossLess; bool running; @@ -102,6 +104,11 @@ delete d; } +void ActionThread::setBackupOriginalRawFile(bool b) +{ + d->backupOriginalRawFile = b; +} + void ActionThread::setCompressLossLess(bool b) { d->compressLossLess = b; @@ -290,6 +297,7 @@ d->dngProcessor.reset(); d->dngProcessor.setInputFile(t->fileUrl.path()); d->dngProcessor.setOutputFile(destPath); + d->dngProcessor.setBackupOriginalRawFile(d->backupOriginalRawFile); d->dngProcessor.setCompressLossLess(d->compressLossLess); d->dngProcessor.setPreviewMode(d->previewMode); int ret = d->dngProcessor.convert(); --- trunk/extragear/graphics/kipi-plugins/dngconverter/plugin/actionthread.h #866899:866900 @@ -50,6 +50,7 @@ ActionThread(QObject *parent); ~ActionThread(); + void setBackupOriginalRawFile(bool b); void setCompressLossLess(bool b); void setPreviewMode(int mode); --- trunk/extragear/graphics/kipi-plugins/dngconverter/plugin/batchdialog.cpp #866899:866900 @@ -281,6 +281,7 @@ KConfig config("kipirc"); KConfigGroup group = config.group(QString("DNGConverter Settings")); + d->settingsBox->setBackupOriginalRawFile(group.readEntry("BackupOriginalRawFile", false)); d->settingsBox->setCompressLossLess(group.readEntry("CompressLossLess", true)); d->settingsBox->setCompressLossLess(group.readEntry("PreviewMode", (int)(DNGWriter::MEDIUM))); d->settingsBox->setConflictRule( @@ -296,9 +297,10 @@ KConfig config("kipirc"); KConfigGroup group = config.group(QString("DNGConverter Settings")); - group.writeEntry("CompressLossLess", d->settingsBox->compressLossLess()); - group.writeEntry("PreviewMode", (int)d->settingsBox->previewMode()); - group.writeEntry("Conflict", (int)d->settingsBox->conflictRule()); + group.writeEntry("BackupOriginalRawFile", d->settingsBox->backupOriginalRawFile()); + group.writeEntry("CompressLossLess", d->settingsBox->compressLossLess()); + group.writeEntry("PreviewMode", (int)d->settingsBox->previewMode()); + group.writeEntry("Conflict", (int)d->settingsBox->conflictRule()); KConfigGroup group2 = config.group(QString("Batch DNG Converter Dialog")); saveDialogSize(group2); @@ -449,6 +451,7 @@ QString file(d->fileList.first()); d->fileList.pop_front(); + d->thread->setBackupOriginalRawFile(d->settingsBox->backupOriginalRawFile()); d->thread->setCompressLossLess(d->settingsBox->compressLossLess()); d->thread->setPreviewMode(d->settingsBox->previewMode()); d->thread->processRawFile(KUrl(file)); --- trunk/extragear/graphics/kipi-plugins/dngconverter/plugin/settingswidget.cpp #866899:866900 @@ -61,13 +61,14 @@ SettingsWidgetPriv() { - conflictLabel = 0; - conflictButtonGroup = 0; - overwriteButton = 0; - promptButton = 0; - compressLossLess = 0; - previewModeCB = 0; - previewModeLabel = 0; + conflictLabel = 0; + conflictButtonGroup = 0; + overwriteButton = 0; + promptButton = 0; + compressLossLess = 0; + previewModeCB = 0; + previewModeLabel = 0; + backupOriginalRawFile = 0; } QLabel *conflictLabel; @@ -79,6 +80,7 @@ QRadioButton *promptButton; QCheckBox *compressLossLess; + QCheckBox *backupOriginalRawFile; RComboBox *previewModeCB; }; @@ -100,6 +102,8 @@ // ------------------------------------------------------------------------ + d->backupOriginalRawFile = new QCheckBox(i18n("Embed Original File"), this); + d->compressLossLess = new QCheckBox(i18n("Lossless Compression"), this); d->previewModeLabel = new QLabel(i18n("JPEG Preview:"), this); @@ -128,14 +132,15 @@ vlay->addWidget(d->overwriteButton); vlay->addWidget(d->promptButton); - settingsBoxLayout->addWidget(dngLogoLabel, 0, 0, 1, 1); - settingsBoxLayout->addWidget(d->compressLossLess, 1, 0, 1, 1); - settingsBoxLayout->addWidget(d->previewModeLabel, 2 ,0, 1, 1); - settingsBoxLayout->addWidget(d->previewModeCB, 3 ,0 ,1, 1); - settingsBoxLayout->addWidget(line, 4, 0, 1, 1); - settingsBoxLayout->addWidget(d->conflictLabel, 5, 0, 1, 1); - settingsBoxLayout->addWidget(conflictBox, 6, 0, 1, 1); - settingsBoxLayout->setRowStretch(7, 10); + settingsBoxLayout->addWidget(dngLogoLabel, 0, 0, 1, 1); + settingsBoxLayout->addWidget(d->backupOriginalRawFile, 1, 0, 1, 1); + settingsBoxLayout->addWidget(d->compressLossLess, 2, 0, 1, 1); + settingsBoxLayout->addWidget(d->previewModeLabel, 3 ,0, 1, 1); + settingsBoxLayout->addWidget(d->previewModeCB, 4 ,0 ,1, 1); + settingsBoxLayout->addWidget(line, 5, 0, 1, 1); + settingsBoxLayout->addWidget(d->conflictLabel, 6, 0, 1, 1); + settingsBoxLayout->addWidget(conflictBox, 7, 0, 1, 1); + settingsBoxLayout->setRowStretch(8, 10); settingsBoxLayout->setMargin(KDialog::spacingHint()); settingsBoxLayout->setSpacing(KDialog::spacingHint()); @@ -157,6 +162,7 @@ { d->previewModeCB->slotReset(); setCompressLossLess(true); + setBackupOriginalRawFile(false); setConflictRule(OVERWRITE); } @@ -180,6 +186,16 @@ return d->compressLossLess->isChecked(); } +void SettingsWidget::setBackupOriginalRawFile(bool b) +{ + d->backupOriginalRawFile->setChecked(b); +} + +bool SettingsWidget::backupOriginalRawFile() const +{ + return d->backupOriginalRawFile->isChecked(); +} + SettingsWidget::ConflictRule SettingsWidget::conflictRule() { return((ConflictRule)(d->conflictButtonGroup->checkedId())); --- trunk/extragear/graphics/kipi-plugins/dngconverter/plugin/settingswidget.h #866899:866900 @@ -58,6 +58,9 @@ void setPreviewMode(int mode); int previewMode() const; + void setBackupOriginalRawFile(bool b); + bool backupOriginalRawFile() const; + void setDefaultSettings(); private slots: _______________________________________________ Digikam-devel mailing list [hidden email] https://mail.kde.org/mailman/listinfo/digikam-devel |
Free forum by Nabble | Edit this page |