Summary: | preview of RAW-Files in album | ||
---|---|---|---|
Product: | [Applications] digikam | Reporter: | Thorsten Schnebeck <thorsten.schnebeck> |
Component: | Preview-RAW | Assignee: | Digikam Developers <digikam-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | CC: | caulier.gilles |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | 7.0.0 |
Description
Thorsten Schnebeck
2004-10-06 19:49:56 UTC
*** This bug has been confirmed by popular vote. *** CVS commit by pahlibar: Use dcraw to generate a quick-image to generate thumbnails for raw images. Its more reliable than using Dave Coffin's parse.c in extracting images and the generation speed seems reasonable BUG: 90875 M +102 -43 digikamthumbnail.cpp 1.13 [POSSIBLY UNSAFE: popen] M +3 -2 digikamthumbnail.h 1.4 --- kdeextragear-3/digikam/kioslave/digikamthumbnail.cpp #1.12:1.13 @@ -52,7 +52,8 @@ extern "C" { #include <stdlib.h> +#include <stdio.h> +#include <string.h> #include <unistd.h> #include <jpeglib.h> -#include <stdio.h> #include <sys/stat.h> #include <sys/types.h> @@ -330,5 +331,9 @@ void kio_digikamthumbnailProtocol::get(c { // Try to load with QT/KDELib API... - img.load(url.path()); + if (!img.load(url.path())) + { + // Try to load with dcraw + loadDCRAW( img, url.path() ); + } } } @@ -557,4 +562,58 @@ bool kio_digikamthumbnailProtocol::loadI } +bool kio_digikamthumbnailProtocol::loadDCRAW(QImage& image, const QString& path) +{ + QCString command; + + // run dcraw with options: + // -c : write to stdout + // -h : Half-size color image (3x faster than -q) + // -2 : 8bit ppm output + // -a : Use automatic white balance + // -w : Use camera white balance, if possible + command = "dcraw -c -h -2 -w -a "; + command += "'"; + command += QFile::encodeName( path ); + command += "'"; + kdDebug() << "Running dcraw command " << command << endl; + + FILE* f = popen( command.data(), "r" ); + + QByteArray imgData; + + if ( !f ) + return false; + + const int MAX_IPC_SIZE = (1024*32); + char buffer[MAX_IPC_SIZE]; + + QFile file; + file.open( IO_ReadOnly, f ); + Q_LONG len; + while ((len = file.readBlock(buffer, MAX_IPC_SIZE)) != 0) + { + if ( len == -1 ) + { + file.close(); + return false; + } + else + { + int oldSize = imgData.size(); + imgData.resize( imgData.size() + len ); + memcpy(imgData.data()+oldSize, buffer, len); + } + } + + file.close(); + pclose( f ); + + if ( imgData.isEmpty() ) + return false; + + image.loadFromData( imgData ); + return true; +} + void kio_digikamthumbnailProtocol::createThumbnailDirs() { --- kdeextragear-3/digikam/kioslave/digikamthumbnail.h #1.3:1.4 @@ -47,4 +47,5 @@ private: bool loadJPEG(QImage& image, const QString& path); bool loadImlib2(QImage& image, const QString& path); + bool loadDCRAW(QImage& image, const QString& path); void createThumbnailDirs(); Not reproducible with digiKam 7.0.0-beta1. |