~ubuntu-branches/ubuntu/karmic/digikam/karmic

« back to all changes in this revision

Viewing changes to utilities/imageeditor/canvas/dimginterface.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Luka Renko
  • Date: 2009-02-14 17:52:28 UTC
  • mfrom: (1.2.19 upstream)
  • Revision ID: james.westby@ubuntu.com-20090214175228-axs6z8e5pgg7bqfx
Tags: 2:0.10.0~rc2-0ubuntu1
* New upstream release (release candidate 2)
* patches/01-kubuntu-fix-armel.patch: 
  - Dropped, included upstream
* control: 
  - Remove quilt from build-depends (no patches)
  - Add liblensfun-dev to build-depends (now in main)

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 * Description : DImg interface for image editor
8
8
 *
9
9
 * Copyright (C) 2004-2005 by Renchi Raju <renchi@pooh.tam.uiuc.edu>
10
 
 * Copyright (C) 2004-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
10
 * Copyright (C) 2004-2009 by Gilles Caulier <caulier dot gilles at gmail dot com>
11
11
 *
12
12
 * This program is free software; you can redistribute it
13
13
 * and/or modify it under the terms of the GNU General
327
327
                    // Ask or apply?
328
328
                    if (d->cmSettings->askOrApplySetting)
329
329
                    {
330
 
                        if (d->parent) d->parent->setCursor( Qt::WaitCursor );
 
330
                        if (d->parent)
 
331
                            d->parent->setCursor( Qt::WaitCursor );
331
332
                        trans.setProfiles(QFile::encodeName(d->cmSettings->inputSetting),
332
333
                                          QFile::encodeName(d->cmSettings->workspaceSetting));
333
334
 
337
338
                                    QFile::exists(d->cmSettings->inputSetting));
338
339
 
339
340
                        d->image.getICCProfilFromFile(QFile::encodeName(d->cmSettings->workspaceSetting));
340
 
                        if (d->parent) d->parent->unsetCursor();
 
341
                        if (d->parent)
 
342
                            d->parent->unsetCursor();
341
343
                    }
342
344
                    else
343
345
                    {
352
354
                        switch (dlg.exec())
353
355
                        {
354
356
                            case QDialog::Accepted:
355
 
                                if (d->parent) d->parent->setCursor( Qt::WaitCursor );
 
357
                                if (d->parent)
 
358
                                    d->parent->setCursor( Qt::WaitCursor );
356
359
 
357
360
                                // NOTE: If Input color profile do not exist, using built-in sRGB instead.
358
361
                                trans.apply(d->image, fakeProfile, d->cmSettings->renderingSetting,
360
363
                                            QFile::exists(d->cmSettings->inputSetting));
361
364
 
362
365
                                d->image.getICCProfilFromFile(QFile::encodeName(d->cmSettings->workspaceSetting));
363
 
                                if (d->parent) d->parent->unsetCursor();
364
 
                            break;
 
366
                                if (d->parent)
 
367
                                    d->parent->unsetCursor();
 
368
                                break;
365
369
                            case -1:
366
 
                                if (d->parent) d->parent->setCursor( Qt::WaitCursor );
 
370
                                if (d->parent)
 
371
                                    d->parent->setCursor( Qt::WaitCursor );
367
372
                                d->image.getICCProfilFromFile(QFile::encodeName(d->cmSettings->workspaceSetting));
368
 
                                if (d->parent) d->parent->unsetCursor();
 
373
                                if (d->parent)
 
374
                                    d->parent->unsetCursor();
369
375
                                kDebug(50003) << "dimginterface.cpp: Apply pressed" << endl;
370
 
                            break;
 
376
                                break;
371
377
                        }
372
378
                    }
373
379
                }
379
385
                    // Ask or apply?
380
386
                    if (d->cmSettings->askOrApplySetting)
381
387
                    {
382
 
                        if (d->parent) d->parent->setCursor( Qt::WaitCursor );
 
388
                        if (d->parent)
 
389
                            d->parent->setCursor( Qt::WaitCursor );
383
390
                        trans.setProfiles(QFile::encodeName(d->cmSettings->workspaceSetting));
384
391
                        trans.apply(d->image, fakeProfile, d->cmSettings->renderingSetting,
385
392
                                    d->cmSettings->BPCSetting, false, false);
386
 
                        if (d->parent) d->parent->unsetCursor();
 
393
                        if (d->parent)
 
394
                            d->parent->unsetCursor();
387
395
                    }
388
396
                    else
389
397
                    {
404
412
                            switch (dlg.exec())
405
413
                            {
406
414
                                case QDialog::Accepted:
407
 
                                    if (d->parent) d->parent->setCursor( Qt::WaitCursor );
 
415
                                    if (d->parent)
 
416
                                        d->parent->setCursor( Qt::WaitCursor );
408
417
                                    trans.apply(d->image, fakeProfile, d->cmSettings->renderingSetting,
409
418
                                                d->cmSettings->BPCSetting, false, false);
410
419
                                    d->image.getICCProfilFromFile(QFile::encodeName(d->cmSettings->workspaceSetting));
411
 
                                    if (d->parent) d->parent->unsetCursor();
412
 
                                break;
 
420
                                    if (d->parent)
 
421
                                        d->parent->unsetCursor();
 
422
                                    break;
413
423
                                case -1:
414
 
                                    if (d->parent) d->parent->setCursor( Qt::WaitCursor );
 
424
                                    if (d->parent)
 
425
                                        d->parent->setCursor( Qt::WaitCursor );
415
426
                                    d->image.getICCProfilFromFile(QFile::encodeName(d->cmSettings->workspaceSetting));
416
 
                                    if (d->parent) d->parent->unsetCursor();
 
427
                                    if (d->parent)
 
428
                                        d->parent->unsetCursor();
417
429
                                    kDebug(50003) << "dimginterface.cpp: Apply pressed" << endl;
418
 
                                break;
 
430
                                    break;
419
431
                            }
420
432
                        }
421
433
                    }
603
615
 
604
616
    // JPEG 2000 file format.
605
617
    if ( mimeType.toUpper() == QString("JP2") || mimeType.toUpper() == QString("JPX") ||
606
 
         mimeType.toUpper() == QString("JPC") || mimeType.toUpper() == QString("PGX"))
 
618
         mimeType.toUpper() == QString("JPC") || mimeType.toUpper() == QString("PGX") || 
 
619
         mimeType.toUpper() == QString("J2K"))
607
620
    {
608
621
        if (iofileSettings->JPEG2000LossLess)
609
622
            d->image.setAttribute("quality", 100);    // LossLess compression
625
638
    // broken. Note that IPTC image preview tag is limited to 256K!!!
626
639
    // There is no limitation with TIFF and PNG about IPTC byte array size.
627
640
 
 
641
    // Before to update IPTC preview, we remove it.
 
642
    meta.removeIptcTag("Iptc.Application2.Preview");
 
643
    meta.removeIptcTag("Iptc.Application2.PreviewFormat");
 
644
    meta.removeIptcTag("Iptc.Application2.PreviewVersion");
 
645
 
628
646
    QSize previewSize = d->image.size();
629
647
    previewSize.scale(1280, 1024, Qt::KeepAspectRatio);
630
648
    QImage preview;
634
652
    else
635
653
        preview = d->image.smoothScale(previewSize.width(), previewSize.height(), Qt::IgnoreAspectRatio).copyQImage();
636
654
 
637
 
    // only store preview if pixel number is at least two times bigger
 
655
    // With JPEG file, we don't store IPTC preview.
 
656
    // NOTE: only store preview if pixel number is at least two times bigger
638
657
    if (/* (2*(previewSize.width() * previewSize.height()) < (int)(d->image.width() * d->image.height())) &&*/
639
658
        (mimeType.toUpper() != QString("JPG") && mimeType.toUpper() != QString("JPEG") &&
640
659
         mimeType.toUpper() != QString("JPE"))
643
662
        // Non JPEG file, we update IPTC preview
644
663
        meta.setImagePreview(preview);
645
664
    }
646
 
    else
647
 
    {
648
 
        // JPEG file, we remove IPTC preview.
649
 
        meta.removeIptcTag("Iptc.Application2.Preview");
650
 
        meta.removeIptcTag("Iptc.Application2.PreviewFormat");
651
 
        meta.removeIptcTag("Iptc.Application2.PreviewVersion");
652
 
    }
653
665
 
654
666
    // Update Exif thumbnail.
655
667
    QImage thumb = preview.scaled(160, 120, Qt::KeepAspectRatio, Qt::SmoothTransformation);