~ubuntu-branches/ubuntu/intrepid/digikam/intrepid

« back to all changes in this revision

Viewing changes to digikam/imageplugins/coreplugin/imageeffect_iccproof.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2008-07-17 20:25:39 UTC
  • mfrom: (1.2.15 upstream) (3.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20080717202539-6n7dtirbkoo7qvhd
Tags: 2:0.9.4-1
* New upstream release
  - digiKam 0.9.4 Release Plan (KDE3) ~ 13 July 08 (Closes: #490144)
* DEB_CONFIGURE_EXTRA_FLAGS := --without-included-sqlite3
* Debhelper compatibility level V7
* Install pixmaps in debian/*.install
* Add debian/digikam.lintian-overrides

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 *               colors using an ICC color profile
9
9
 *
10
10
 * Copyright (C) 2005-2006 by F.J. Cruz <fj.cruz@supercable.es>
11
 
 * Copyright (C) 2006-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
11
 * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
12
12
 *
13
13
 * This program is free software; you can redistribute it
14
14
 * and/or modify it under the terms of the GNU General
121
121
    m_channelCB->insertItem(i18n("Red"));
122
122
    m_channelCB->insertItem(i18n("Green"));
123
123
    m_channelCB->insertItem(i18n("Blue"));
124
 
    QWhatsThis::add( m_channelCB, i18n("<p>Select here the histogram channel to display:<p>"
 
124
    QWhatsThis::add( m_channelCB, i18n("<p>Select the histogram channel to display here:<p>"
125
125
                                       "<b>Luminosity</b>: display the image's luminosity values.<p>"
126
126
                                       "<b>Red</b>: display the red channel values.<p>"
127
127
                                       "<b>Green</b>: display the green channel values.<p>"
131
131
    m_scaleBG->setExclusive(true);
132
132
    m_scaleBG->setFrameShape(QFrame::NoFrame);
133
133
    m_scaleBG->setInsideMargin( 0 );
134
 
    QWhatsThis::add( m_scaleBG, i18n("<p>Select here the histogram scale.<p>"
 
134
    QWhatsThis::add( m_scaleBG, i18n("<p>Select the histogram scale here.<p>"
135
135
                                     "If the image's maximal values are small, you can use the linear scale.<p>"
136
136
                                     "Logarithmic scale can be used when the maximal values are big; "
137
137
                                     "if it is used, all values (small and large) will be visible on the "
196
196
    m_doSoftProofBox = new QCheckBox(generalOptions);
197
197
    m_doSoftProofBox->setText(i18n("Soft-proofing"));
198
198
    QWhatsThis::add(m_doSoftProofBox, i18n("<p>Rendering emulation of the device described "
199
 
                                           "by the \"Proofing\" profile. Useful to preview final "
 
199
                                           "by the \"Proofing\" profile. Useful to preview the final "
200
200
                                           "result without rendering to physical medium.</p>"));
201
201
 
202
202
    m_checkGamutBox = new QCheckBox(generalOptions);
208
208
    m_embeddProfileBox->setChecked(true);
209
209
    m_embeddProfileBox->setText(i18n("Assign profile"));
210
210
    QWhatsThis::add(m_embeddProfileBox, i18n("<p>You can use this option to embed "
211
 
                                             "the selected work-space color profile into the image.</p>"));
 
211
                                             "the selected workspace color profile into the image.</p>"));
212
212
 
213
213
    m_BPCBox = new QCheckBox(generalOptions);
214
214
    m_BPCBox->setText(i18n("Use BPC"));
216
216
                                   "with Relative Colorimetric Intent. Perceptual intent should make no "
217
217
                                   "difference, since BPC is always on, and in Absolute Colorimetric "
218
218
                   "Intent it is always turned off.</p>"
219
 
                                   "<p>BPC does compensate a lack of ICC profiles in the dark tone rendering."
 
219
                                   "<p>BPC does compensate for a lack of ICC profiles in the dark tone rendering. "
220
220
                                   "With BPC the dark tones are optimally mapped (no clipping) from original media "
221
 
                                   "to the destination media can render, e.g. the combination paper/ink.</p>"));
 
221
                                   "to the destination rendering media, e.g. the combination of paper and ink.</p>"));
222
222
 
223
223
    QLabel *intent = new QLabel(i18n("Rendering Intent:"), generalOptions);
224
224
    m_renderingIntentsCB = new QComboBox(false, generalOptions);
231
231
                "so that gray balance is preserved but colorimetric accuracy may not be preserved.<br>"
232
232
                "In other words, if certain colors in an image fall outside of the range of colors that "
233
233
                "the output device can render, the image intent will cause all the colors in the image "
234
 
                "to be adjusted so that the every color in the image falls within the range that can be "
 
234
                "to be adjusted so that every color in the image falls within the range that can be "
235
235
                "rendered and so that the relationship between colors is preserved as much as possible.<br>"
236
236
                "This intent is most suitable for display of photographs and images, and is the default "
237
237
                "intent.</li>"
238
238
                "<li> Absolute Colorimetric intent causes any colors that fall outside the range that the "
239
 
                "output device can render are adjusted to the closest color that can be rendered, while all "
 
239
                "output device can render to be adjusted to the closest color that can be rendered, while all "
240
240
                "other colors are left unchanged.<br>"
241
241
                "This intent preserves the white point and is most suitable for spot colors (Pantone, "
242
242
                "TruMatch, logo colors, ...).</li>"
305
305
    QPushButton *inProfilesInfo = new QPushButton(i18n("Info..."), inProfiles);
306
306
 
307
307
    QGroupBox *pictureInfo = new QGroupBox(2, Qt::Horizontal, i18n("Camera information"), inProfiles);
308
 
    new QLabel(i18n("Brand:"), pictureInfo);
 
308
    new QLabel(i18n("Make:"), pictureInfo);
309
309
    KSqueezedTextLabel *make  = new KSqueezedTextLabel(0, pictureInfo);
310
310
    new QLabel(i18n("Model:"), pictureInfo);
311
311
    KSqueezedTextLabel *model = new KSqueezedTextLabel(0, pictureInfo);
322
322
    //---------- "Workspace" Page Setup ---------------------------------
323
323
 
324
324
    m_toolBoxWidgets->insertItem(WORKSPACEPAGE, spaceProfiles, 
325
 
                                 SmallIconSet("tablet"), i18n("Work-space Profile"));
326
 
    QWhatsThis::add(spaceProfiles, i18n("<p>Set here all parameters relevant of Color Work-space "
 
325
                                 SmallIconSet("tablet"), i18n("Workspace Profile"));
 
326
    QWhatsThis::add(spaceProfiles, i18n("<p>Set here all parameters relevant to Color Workspace "
327
327
                    "Profiles.</p>"));
328
328
 
329
329
    QGridLayout *secondPageLayout = new QGridLayout(spaceProfiles, 3, 2, spacingHint());
392
392
 
393
393
    m_toolBoxWidgets->insertItem(LIGHTNESSPAGE, lightnessadjust, 
394
394
                                 SmallIconSet("blend"), i18n("Lightness Adjustments"));
395
 
    QWhatsThis::add(lightnessadjust, i18n("<p>Set here all lightness adjustments of target image.</p>"));
 
395
    QWhatsThis::add(lightnessadjust, i18n("<p>Set here all lightness adjustments to the target image.</p>"));
396
396
 
397
397
    QGridLayout *fourPageLayout = new QGridLayout( lightnessadjust, 5, 2, spacingHint(), 0);
398
398
 
492
492
            this, SLOT(slotEffect()));      
493
493
 
494
494
    //-- Image preview widget connections ----------------------------
495
 
    
 
495
 
496
496
    connect(m_previewWidget, SIGNAL(signalResized()),
497
497
            this, SLOT(slotEffect()));
498
 
            
 
498
 
499
499
    connect(m_previewWidget, SIGNAL(spotPositionChangedFromOriginal( const Digikam::DColor &, const QPoint & )),
500
500
            this, SLOT(slotSpotColorChanged( const Digikam::DColor & )));
501
501
 
529
529
{
530
530
    QString defaultICCPath = KGlobalSettings::documentPath();
531
531
    KConfig* config        = kapp->config();
532
 
    
533
 
    // General settings of digiKam Color Management                            
 
532
 
 
533
    // General settings of digiKam Color Management
534
534
    config->setGroup("Color Management");
535
535
 
536
536
    if (!config->readBoolEntry("EnableCM", false))
543
543
        m_inPath      = config->readPathEntry("InProfileFile");
544
544
        m_spacePath   = config->readPathEntry("WorkProfileFile");
545
545
        m_proofPath   = config->readPathEntry("ProofProfileFile");
546
 
        
 
546
 
547
547
        if (QFile::exists(config->readPathEntry("DefaultPath")))
548
548
        {
549
549
            defaultICCPath = config->readPathEntry("DefaultPath");
550
550
        }
551
551
        else
552
552
        {
553
 
            QString message = i18n("ICC profiles path seems to be invalid. You'll not be able to use \"Default profile\"\
554
 
                                    options.<p>Please solve it in digiKam ICC setup.");
 
553
            QString message = i18n("The ICC profiles path seems to be invalid. You won't be able to use the \"Default profile\"\
 
554
                                    options.<p>Please fix this in the digiKam ICC setup.");
555
555
            slotToggledWidgets( false );
556
556
            KMessageBox::information(this, message);
557
557
        }
558
558
    }
559
 
    
 
559
 
560
560
    // Plugin settings.
561
561
    config->setGroup("colormanagement Tool Dialog");
562
562
    m_channelCB->setCurrentItem(config->readNumEntry("Histogram Channel", 0));    // Luminosity.
563
563
    m_scaleBG->setButton(config->readNumEntry("Histogram Scale", Digikam::HistogramWidget::LogScaleHistogram));
564
 
    m_toolBoxWidgets->setCurrentIndex(config->readNumEntry("Settings Tab", GENERALPAGE));        
 
564
    m_toolBoxWidgets->setCurrentIndex(config->readNumEntry("Settings Tab", GENERALPAGE));
565
565
    m_inProfilesPath->setURL(config->readPathEntry("InputProfilePath", defaultICCPath)); 
566
566
    m_proofProfilePath->setURL(config->readPathEntry("ProofProfilePath", defaultICCPath)); 
567
567
    m_spaceProfilePath->setURL(config->readPathEntry("SpaceProfilePath", defaultICCPath));
661
661
            m_histogramWidget->m_channelType = Digikam::HistogramWidget::ValueHistogram;
662
662
            m_hGradient->setColors( QColor( "black" ), QColor( "white" ) );
663
663
            break;
664
 
    
 
664
 
665
665
        case RedChannel:
666
666
            m_histogramWidget->m_channelType = Digikam::HistogramWidget::RedChannelHistogram;
667
667
            m_hGradient->setColors( QColor( "black" ), QColor( "red" ) );
668
668
            break;
669
 
    
670
 
        case GreenChannel:         
 
669
 
 
670
        case GreenChannel:
671
671
            m_histogramWidget->m_channelType = Digikam::HistogramWidget::GreenChannelHistogram;
672
672
            m_hGradient->setColors( QColor( "black" ), QColor( "green" ) );
673
673
            break;
674
 
    
675
 
        case BlueChannel:         
 
674
 
 
675
        case BlueChannel:
676
676
            m_histogramWidget->m_channelType = Digikam::HistogramWidget::BlueChannelHistogram;
677
677
            m_hGradient->setColors( QColor( "black" ), QColor( "blue" ) );
678
678
            break;
725
725
 
726
726
    bool proofCondition = false;
727
727
    bool spaceCondition = false;
728
 
    
 
728
 
729
729
    //-- Input profile parameters ------------------
730
 
    
 
730
 
731
731
    if (useDefaultInProfile())
732
732
    {
733
733
        tmpInPath = m_inPath;
738
738
        QFileInfo info(tmpInPath);
739
739
        if (!info.exists() || !info.isReadable() || !info.isFile() )
740
740
        {
741
 
            KMessageBox::information(this, i18n("<p>Selected ICC input profile path seems to be invalid.<p>"
 
741
            KMessageBox::information(this, i18n("<p>The selected ICC input profile path seems to be invalid.<p>"
742
742
                                                "Please check it."));
743
743
            return;
744
744
        }
756
756
        QFileInfo info(tmpProofPath);
757
757
        if (!info.exists() || !info.isReadable() || !info.isFile() )
758
758
        {
759
 
            KMessageBox::information(this, i18n("<p>Selected ICC proof profile path seems to be invalid.<p>"
 
759
            KMessageBox::information(this, i18n("<p>The selected ICC proof profile path seems to be invalid.<p>"
760
760
                                                "Please check it."));
761
761
            return;
762
762
        }
837
837
            transform.apply(preview, fakeProfile, m_renderingIntentsCB->currentItem(), useBPC(),
838
838
                            m_checkGamutBox->isChecked(), useBuiltinProfile());
839
839
        }
840
 
        
 
840
 
841
841
        //-- Calculate and apply the curve on image after transformation -------------
842
 
        
 
842
 
843
843
        Digikam::DImg preview2(w, h, sb, a, 0, false);
844
844
        m_curves->curvesLutSetup(Digikam::ImageHistogram::AlphaChannel);
845
845
        m_curves->curvesLutProcess(preview.bits(), preview2.bits(), w, h);
846
 
    
 
846
 
847
847
        //-- Adjust contrast ---------------------------------------------------------
848
 
        
 
848
 
849
849
        Digikam::BCGModifier cmod;
850
850
        cmod.setContrast((double)(m_cInput->value()/100.0) + 1.00);
851
851
        cmod.applyBCG(preview2);
854
854
        m_previewWidget->updatePreview();
855
855
 
856
856
        //-- Update histogram --------------------------------------------------------
857
 
    
 
857
 
858
858
        memcpy(m_destinationPreviewData, preview2.bits(), preview2.numBytes());
859
859
        m_histogramWidget->updateData(m_destinationPreviewData, w, h, sb, 0, 0, 0, false);
860
860
        kapp->restoreOverrideCursor();
861
 
    }    
 
861
    }
862
862
}
863
863
 
864
864
void ImageEffect_ICCProof::finalRendering()
866
866
    if (!m_doSoftProofBox->isChecked())
867
867
    {
868
868
        kapp->setOverrideCursor( KCursor::waitCursor() );
869
 
        
 
869
 
870
870
        Digikam::ImageIface *iface = m_previewWidget->imageIface();
871
871
        uchar *data                = iface->getOriginalImage();
872
872
        int w                      = iface->originalWidth();
877
877
        if (data)
878
878
        {
879
879
            Digikam::IccTransform transform;
880
 
            
 
880
 
881
881
            Digikam::DImg img(w, h, sb, a, data);
882
882
 
883
883
            QString tmpInPath;
884
884
            QString tmpProofPath;
885
885
            QString tmpSpacePath;
886
886
            bool proofCondition;
887
 
            
 
887
 
888
888
            //-- Input profile parameters ------------------
889
 
            
 
889
 
890
890
            if (useDefaultInProfile())
891
891
            {
892
892
                tmpInPath = m_inPath;
904
904
            }
905
905
 
906
906
            //-- Proof profile parameters ------------------
907
 
        
 
907
 
908
908
            if (useDefaultProofProfile())
909
909
            {
910
910
                tmpProofPath = m_proofPath;
915
915
                QFileInfo info(tmpProofPath);
916
916
                if (!info.exists() || !info.isReadable() || !info.isFile() )
917
917
                {
918
 
                    KMessageBox::information(this, i18n("<p>Selected ICC proof profile path seems "
 
918
                    KMessageBox::information(this, i18n("<p>The selected ICC proof profile path seems "
919
919
                                                        "to be invalid.<p>Please check it."));
920
920
                    return;
921
921
                }
923
923
 
924
924
            if (tmpProofPath.isNull())
925
925
                proofCondition = false;
926
 
        
 
926
 
927
927
            //-- Workspace profile parameters --------------
928
 
        
 
928
 
929
929
            if (useDefaultSpaceProfile())
930
930
            {
931
931
                tmpSpacePath = m_spacePath;
941
941
                    return;
942
942
                }
943
943
            }
944
 
        
 
944
 
945
945
            //-- Perform the color transformations ------------------
946
 
        
 
946
 
947
947
            transform.getTransformType(m_doSoftProofBox->isChecked());
948
 
        
 
948
 
949
949
            if (m_doSoftProofBox->isChecked())
950
950
            {
951
951
                if (m_useEmbeddedProfile->isChecked())
968
968
                    transform.setProfiles( tmpInPath, tmpSpacePath );
969
969
                }
970
970
            }
971
 
            
 
971
 
972
972
            if (m_useEmbeddedProfile->isChecked())
973
973
            {
974
974
                transform.apply(img, m_embeddedICC, m_renderingIntentsCB->currentItem(), useBPC(),
980
980
                transform.apply(img, fakeProfile, m_renderingIntentsCB->currentItem(), useBPC(),
981
981
                                m_checkGamutBox->isChecked(), useBuiltinProfile());
982
982
            }
983
 
    
 
983
 
984
984
            //-- Embed the workspace profile if necessary --------------------------------
985
 
   
 
985
 
986
986
            if (m_embeddProfileBox->isChecked())
987
987
            {
988
988
                iface->setEmbeddedICCToOriginalImage( tmpSpacePath );
990
990
            }
991
991
 
992
992
            //-- Calculate and apply the curve on image after transformation -------------
993
 
        
 
993
 
994
994
            Digikam::DImg img2(w, h, sb, a, 0, false);
995
995
            m_curves->curvesLutSetup(Digikam::ImageHistogram::AlphaChannel);
996
996
            m_curves->curvesLutProcess(img.bits(), img2.bits(), w, h);
997
 
        
 
997
 
998
998
            //-- Adjust contrast ---------------------------------------------------------
999
 
            
 
999
 
1000
1000
            Digikam::BCGModifier cmod;
1001
1001
            cmod.setContrast((double)(m_cInput->value()/100.0) + 1.00);
1002
1002
            cmod.applyBCG(img2);
1003
 
    
 
1003
 
1004
1004
            iface->putOriginalImage("Color Management", img2.bits());
1005
1005
            delete [] data;
1006
1006
        }
1072
1072
        KMessageBox::error(this, i18n("Sorry, there is no selected profile"), i18n("Profile Error"));
1073
1073
        return;
1074
1074
    }
1075
 
    
 
1075
 
1076
1076
    Digikam::ICCProfileInfoDlg infoDlg(this, profile);
1077
1077
    infoDlg.exec();
1078
1078
}
1093
1093
{
1094
1094
    if (!m_cmEnabled)
1095
1095
    {
1096
 
        QString message = i18n("<p>You do not have enabled Color Management in digiKam preferences.</p>");
 
1096
        QString message = i18n("<p>You have not enabled Color Management in the digiKam preferences.</p>");
1097
1097
        message.append( i18n("<p>\"Use of default profile\" options will be disabled now.</p>"));
1098
1098
        KMessageBox::information(this, message);
1099
1099
        slotToggledWidgets(false);
1169
1169
       return;
1170
1170
 
1171
1171
    QFile file(loadColorManagementFile.path());
1172
 
    
 
1172
 
1173
1173
    if ( file.open(IO_ReadOnly) )   
1174
1174
    {
1175
1175
        QTextStream stream( &file );
1179
1179
           KMessageBox::error(this, 
1180
1180
                        i18n("\"%1\" is not a Color Management settings text file.")
1181
1181
                        .arg(loadColorManagementFile.fileName()));
1182
 
           file.close();            
 
1182
           file.close();
1183
1183
           return;
1184
1184
        }
1185
 
        
 
1185
 
1186
1186
        blockSignals(true);
1187
 
        
 
1187
 
1188
1188
        m_renderingIntentsCB->setCurrentItem( stream.readLine().toInt() );
1189
1189
        m_doSoftProofBox->setChecked( (bool)(stream.readLine().toUInt()) );
1190
1190
        m_checkGamutBox->setChecked( (bool)(stream.readLine().toUInt()) );
1210
1210
            QPoint p;
1211
1211
            p.setX( stream.readLine().toInt() );
1212
1212
            p.setY( stream.readLine().toInt() );
1213
 
    
 
1213
 
1214
1214
            if (m_originalImage->sixteenBit() && p != disable)
1215
1215
            {
1216
1216
                p.setX(p.x()*255);
1217
1217
                p.setY(p.y()*255);
1218
1218
            }
1219
 
    
 
1219
 
1220
1220
            m_curves->setCurvePoint(Digikam::ImageHistogram::ValueChannel, j, p);
1221
1221
        }
1222
1222
 
1231
1231
    else
1232
1232
        KMessageBox::error(this, i18n("Cannot load settings from the Color Management text file."));
1233
1233
 
1234
 
    file.close();            
 
1234
    file.close();
1235
1235
}
1236
1236
 
1237
1237
//-- Save all settings to file ---------------------------------------
1245
1245
       return;
1246
1246
 
1247
1247
    QFile file(saveColorManagementFile.path());
1248
 
    
 
1248
 
1249
1249
    if ( file.open(IO_WriteOnly) )   
1250
1250
    {
1251
1251
        QTextStream stream( &file );        
1277
1277
    }
1278
1278
    else
1279
1279
        KMessageBox::error(this, i18n("Cannot save settings to the Color Management text file."));
1280
 
    
1281
 
    file.close();        
 
1280
 
 
1281
    file.close();
1282
1282
}
1283
1283
 
1284
1284
} // NameSpace DigikamImagesPluginCore
1285