~ubuntu-branches/ubuntu/feisty/digikam/feisty

« back to all changes in this revision

Viewing changes to digikam/utilities/cameragui/umscamera.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Achim Bohnet
  • Date: 2006-05-15 01:15:02 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515011502-kpyuz7766hpbuia8
Tags: 0.8.2~rc1-0ubuntu1
* sync with debian (UVF see #44102)
  0.8.2~rc1-0ubuntu1 is identical to debian's 0.8.1+0.8.2-rc1-1.
  Version was changed due to latest 0.8.1.ubuntu-0ubuntu1 upload.
  This version is unfortunately bigger than debian's 0.8.1+0.8.2-rc1-1
* Merge in ubuntu changelog

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 * Description : 
6
6
 * 
7
7
 * Copyright 2004-2005 by Renchi Raju
8
 
 * Copyright 2005 by Gilles Caulier
 
8
 * Copyright 2005-2006 by Gilles Caulier
9
9
 *
10
10
 * This program is free software; you can redistribute it
11
11
 * and/or modify it under the terms of the GNU General
138
138
    return true;
139
139
}
140
140
 
141
 
bool UMSCamera::getThumbnail(const QString& folder,
142
 
                             const QString& itemName,
143
 
                             QImage& thumbnail)
 
141
bool UMSCamera::getThumbnail(const QString& folder, const QString& itemName, QImage& thumbnail)
144
142
{
145
143
    m_cancel = false;
146
144
 
147
 
    // Trying to get thumbnail from Exif data.
 
145
    // In 1st, we trying to get thumbnail from Exif data if we are JPEG file.
148
146
 
149
147
    KExifData exifData;
150
148
    
154
152
        if (!thumbnail.isNull())
155
153
           return true;
156
154
    }
157
 
 
158
 
   // Trying to get thumbnail from RAW file using dcraw parse utility.
 
155
 
 
156
    // In 2th, we trying to get thumbnail from '.thm' files if we didn't manage to get
 
157
    // thumbnail from Exif. Any cameras provides *.thm files like JPEG files with RAW files. 
 
158
    // Using this way is always more speed than using dcraw parse utility.
 
159
    // 2006/27/01 - Gilles - Tested with my Minolta Dynax 5D USM camera.
 
160
 
 
161
    QFileInfo fi(folder + "/" + itemName);
 
162
 
 
163
    if (thumbnail.load(folder + "/" + fi.baseName() + ".thm"))        // Lowercase
 
164
    {
 
165
        if (!thumbnail.isNull())
 
166
           return true;
 
167
    }
 
168
    else if (thumbnail.load(folder + "/" + fi.baseName() + ".THM"))   // Uppercase
 
169
    {
 
170
        if (!thumbnail.isNull())
 
171
           return true;
 
172
    }   
 
173
 
 
174
    // In 3rd, if file image type is TIFF, load thumb using KDELib API before to use dcraw::parse method 
 
175
    // to prevent broken 16 bits TIFF thumb.
 
176
 
 
177
    if (fi.extension().upper() == QString("TIFF") ||
 
178
        fi.extension().upper() == QString("TIF"))
 
179
    {
 
180
        thumbnail.load(folder + "/" + itemName);
 
181
    
 
182
        if (!thumbnail.isNull())
 
183
            return true;
 
184
    }
 
185
 
 
186
    // In 4th we trying to get thumbnail from RAW files using dcraw parse utility.
159
187
 
160
188
    KTempFile thumbFile(QString::null, "camerarawthumb");
161
189
    thumbFile.setAutoDelete(true);
164
192
    if (thumbFile.status() == 0)
165
193
    {
166
194
        if (rawFileParser.getThumbnail(QFile::encodeName(folder + "/" + itemName),
167
 
                                    QFile::encodeName(thumbFile.name())) == 0)
 
195
                                       QFile::encodeName(thumbFile.name())) == 0)
168
196
        {
169
197
            thumbnail.load(thumbFile.name());
170
198
            if (!thumbnail.isNull())
171
199
                return true;
172
200
        }
173
201
    }
174
 
 
175
 
    // TODO: check for thm files if we didn't manage to get thumbnail from exif
176
 
    
 
202
    
 
203
    // Finaly, we trying to get thumbnail using KDELib API. This way can take a while.
 
204
    
 
205
    thumbnail.load(folder + "/" + itemName);
 
206
 
 
207
    if (!thumbnail.isNull())
 
208
        return true;
 
209
 
177
210
    return false;
178
211
}
179
212
 
250
283
{
251
284
    m_cancel = false;
252
285
 
 
286
    // Any camera provide THM (thumbnail) file with real image. We need to remove it also.
 
287
 
 
288
    QFileInfo fi(folder + "/" + itemName);
 
289
 
 
290
    QFileInfo thmLo(folder + "/" + fi.baseName() + ".thm");          // Lowercase
 
291
 
 
292
    if (thmLo.exists())           
 
293
        ::unlink(QFile::encodeName(thmLo.filePath()));
 
294
 
 
295
    QFileInfo thmUp(folder + "/" + fi.baseName() + ".THM");          // Uppercase
 
296
 
 
297
    if (thmUp.exists())           
 
298
        ::unlink(QFile::encodeName(thmUp.filePath()));
 
299
 
 
300
    // Remove the real image.
253
301
    return (::unlink(QFile::encodeName(folder + "/" + itemName)) == 0);
254
302
}
255
303