[Digikam-devel] extragear/graphics/digikam/utilities/imageeditor/canvas
Francisco J. Cruz
fj.cruz at supercable.es
Mon Dec 12 21:35:28 GMT 2005
SVN commit 488014 by fjcruz:
Real dynamic support for color management, using settings from dialog setup has been added. Please test and report.
CCMAIL:digikam-devel at kde.org
M +43 -0 canvas.cpp
M +2 -0 canvas.h
M +119 -3 dimginterface.cpp
M +3 -0 dimginterface.h
--- trunk/extragear/graphics/digikam/utilities/imageeditor/canvas/canvas.cpp #488013:488014
@@ -53,6 +53,7 @@
#include "imagehistogram.h"
#include "dimginterface.h"
#include "canvas.h"
+#include "iccsettingscontainer.h"
const int HISTOGRAM_WIDTH = (256 * 4) / 3;
const int HISTOGRAM_HEIGHT = (114 * 4) / 3;
@@ -380,6 +381,48 @@
return (isReadOnly);
}
+bool Canvas::load(const QString& filename, ICCSettingsContainer *settingsContainer, QWidget *pointer)
+{
+ // FIXME implement this overloaded method
+
+ if (d->rubber) {
+ delete d->rubber;
+ d->rubber = 0;
+ emit signalSelected(false);
+ }
+
+ if (d->imageHistogram)
+ {
+ delete d->imageHistogram;
+ d->imageHistogram = 0;
+ }
+
+ viewport()->setUpdatesEnabled(false);
+
+ d->tileCache.clear();
+
+ bool isReadOnly = true;
+ d->im->load( filename, &isReadOnly, settingsContainer, pointer );
+
+ d->zoom = 1.0;
+ d->im->zoom(d->zoom);
+
+ if (d->autoZoom)
+ updateAutoZoom();
+
+ updateContentsSize();
+
+ viewport()->setUpdatesEnabled(true);
+ viewport()->update();
+ if (d->showHistogram)
+ updateHistogram(true);
+
+ emit signalChanged(false, false);
+ emit signalZoomChanged(d->zoom);
+
+ return (isReadOnly);
+}
+
void Canvas::preload(const QString& /*filename*/)
{
// d->im->preload(filename);
--- trunk/extragear/graphics/digikam/utilities/imageeditor/canvas/canvas.h #488013:488014
@@ -37,6 +37,7 @@
class QColor;
class CanvasPrivate;
+class ICCSettingsContainer;
class Canvas : public QScrollView {
@@ -48,6 +49,7 @@
~Canvas();
bool load(const QString& filename);
+ bool load(const QString& filename, ICCSettingsContainer *settingsContainer, QWidget *pointer);
void preload(const QString& filename);
int save(const QString& filename, int JPEGcompression,
int PNGcompression, bool TIFFcompression);
--- trunk/extragear/graphics/digikam/utilities/imageeditor/canvas/dimginterface.cpp #488013:488014
@@ -40,6 +40,7 @@
// KDE includes.
#include <kdebug.h>
+#include <kmessagebox.h>
// Local includes.
@@ -48,6 +49,7 @@
#include "undomanager.h"
#include "undoaction.h"
#include "dimginterface.h"
+#include "iccsettingscontainer.h"
namespace Digikam
{
@@ -153,14 +155,127 @@
*isReadOnly = d->image.isReadOnly();
valRet = true;
+ }
+ else
+ {
+ kdWarning() << k_funcinfo << "Failed to load image " << endl;
+ valRet = false;
+ }
- // Paco, uncomment this code to test ICC profil transformation.
- // It's harcoded actually until we make a setup dialog tab about ICC profil.
+ if (d->exifOrient)
+ {
+ exifRotate(filename);
+ }
+
+ return (valRet);
+}
+
+bool DImgInterface::load(const QString& filename, bool *isReadOnly, ICCSettingsContainer *cmSettings, QWidget *pointer)
+{
+
+
+ bool valRet;
+ bool apply;
+
+ *isReadOnly = true;
+ d->valid = false;
+
+ d->filename = filename;
+
+ d->width = 0;
+ d->height = 0;
+ d->origWidth = 0;
+ d->origHeight = 0;
+ d->selX = 0;
+ d->selY = 0;
+ d->selW = 0;
+ d->selH = 0;
+ d->gamma = 1.0;
+ d->contrast = 1.0;
+ d->brightness = 0.0;
+ d->cmod.reset();
+
+ d->undoMan->clear();
+
+ d->image = DImg(filename);
+
+ if (!d->image.isNull())
+ {
+ d->origWidth = d->image.width();
+ d->origHeight = d->image.height();
+ d->valid = true;
+
+ d->width = d->origWidth;
+ d->height = d->origHeight;
+
+ *isReadOnly = d->image.isReadOnly();
+ valRet = true;
+
+ // FIXME Implement transformations.
/*
IccTransform trans;
trans.setProfiles("/home/gilles/Canon-EOS10D-linear.icc", "/home/gilles/AdobeRGB1998.icc");
- trans.apply(d->image);
+ trans.apply(d->image);
*/
+
+ if (cmSettings->askOrApplySetting)
+ {
+ apply = true;
+ }
+ else
+ {
+ apply = false;
+ }
+
+ IccTransform trans;
+
+ // First possibility: image has no embedded profile
+ if(d->image.getICCProfil().isNull())
+ {
+ // Ask or apply?
+ if (apply)
+ {
+ trans.setProfiles( QFile::encodeName(cmSettings->inputSetting), QFile::encodeName(cmSettings->workspaceSetting));
+ trans.apply( d->image );
+ }
+ else
+ {
+ QString message = i18n("<p>This image has not assigned any color profile<p><p>Do you want to convert it to your workspace color profile?</p><p>Current workspace color profile: ") + trans.getProfileDescription( cmSettings->workspaceSetting ) + "</p>";
+
+ if (KMessageBox::questionYesNo(pointer, message) == KMessageBox::Yes)
+ {
+ kdDebug() << "Pressed YES" << endl;
+ trans.setProfiles( QFile::encodeName(cmSettings->inputSetting), QFile::encodeName(cmSettings->workspaceSetting));
+ trans.apply( d->image );
+ }
+ }
+ }
+ // Second possibility: image has an embedded profile
+ else
+ {
+ trans.getEmbeddedProfile( d->image );
+
+ if (apply)
+ {
+ trans.setProfiles(QFile::encodeName(cmSettings->workspaceSetting));
+ trans.apply( d->image );
+ }
+ else
+ {
+ if (trans.getEmbeddedProfileDescriptor()
+ != trans.getProfileDescription( cmSettings->workspaceSetting ))
+ {
+ kdDebug() << "Embedded profile: " << trans.getEmbeddedProfileDescriptor() << endl;
+ QString message = i18n("<p>This image has assigned a color profile that does not match with your default workspace color profile.<p><p>Do you want to convert it to your workspace color profile?</p><p>Current workspace color profile:<b> ") + trans.getProfileDescription( cmSettings->workspaceSetting ) + i18n("</b></p><p>Image Color Profile:<b> ") + trans.getEmbeddedProfileDescriptor() + "</b></p>";
+
+ if (KMessageBox::questionYesNo(pointer, message) == KMessageBox::Yes)
+ {
+ trans.setProfiles( QFile::encodeName(cmSettings->workspaceSetting));
+ trans.apply( d->image );
+ }
+ }
+ }
+ }
}
else
{
@@ -174,6 +289,7 @@
}
return (valRet);
+
}
bool DImgInterface::exifRotated()
--- trunk/extragear/graphics/digikam/utilities/imageeditor/canvas/dimginterface.h #488013:488014
@@ -39,6 +39,8 @@
class QString;
class QPixmap;
+class ICCSettingsContainer;
+
namespace Digikam
{
@@ -55,6 +57,7 @@
~DImgInterface();
bool load(const QString& filename, bool *isReadOnly);
+ bool load(const QString& filename, bool *isReadOnly, ICCSettingsContainer *cmSettings, QWidget *pointer);
void setExifOrient(bool exifOrient);
void undo();
void redo();
More information about the Digikam-devel
mailing list