SVN commit 496361 by cgilles:
digikam from trunk : New option to convert an image from 8 to 16 bits/color/pixel and vis-versa. CCMAIL: [hidden email] M +6 -1 imageplugins/digikamimageplugin_core_ui.rc M +52 -3 imageplugins/imageplugin_core.cpp M +5 -0 imageplugins/imageplugin_core.h M +9 -1 utilities/imageeditor/canvas/dimginterface.cpp M +3 -1 utilities/imageeditor/canvas/dimginterface.h M +5 -0 utilities/imageeditor/editor/imageiface.cpp M +2 -0 utilities/imageeditor/editor/imageiface.h --- trunk/extragear/graphics/digikam/imageplugins/digikamimageplugin_core_ui.rc #496360:496361 @@ -1,5 +1,5 @@ <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> -<kpartgui version="2" name="digikamimageplugin_core" > +<kpartgui version="3" name="digikamimageplugin_core" > <MenuBar> @@ -13,6 +13,11 @@ <Separator /> <Action name="implugcore_autocorrection" /> <Action name="implugcore_invert" /> + <Menu name="Depth"> + <text>&Depth</text> + <Action name="implugcore_convertto8bits" /> + <Action name="implugcore_convertto16bits" /> + </Menu> <Separator /> <Action name="implugcore_colormanagement" /> <Separator /> --- trunk/extragear/graphics/digikam/imageplugins/imageplugin_core.cpp #496360:496361 @@ -20,15 +20,16 @@ * * ============================================================ */ +#include <config.h> + // KDE includes. -#include <config.h> - #include <klocale.h> #include <kgenericfactory.h> #include <klibloader.h> #include <kaction.h> #include <kcursor.h> +#include <kmessagebox.h> #include <kdebug.h> // Local includes. @@ -91,7 +92,15 @@ m_invertAction = new KAction(i18n("Invert"), "invertimage", 0, this, SLOT(slotInvert()), actionCollection(), "implugcore_invert"); + + m_convertTo8Bits = new KAction(i18n("8 bits"), 0, 0, + this, SLOT(slotConvertTo8Bits()), + actionCollection(), "implugcore_convertto8bits"); + m_convertTo8Bits = new KAction(i18n("16 bits"), 0, 0, + this, SLOT(slotConvertTo16Bits()), + actionCollection(), "implugcore_convertto16bits"); + m_colorManagementAction = new KAction(i18n("Color Management..."), "colormanagement", 0, this, SLOT(slotColorManagement()), actionCollection(), "implugcore_colormanagement"); @@ -138,6 +147,8 @@ m_sharpenAction->setEnabled(enable); m_blurAction->setEnabled(enable); m_colorManagementAction->setEnabled(enable); + m_convertTo8Bits->setEnabled(enable); + m_convertTo16Bits->setEnabled(enable); } void ImagePlugin_Core::slotBlur() @@ -189,8 +200,9 @@ Digikam::ImageFilters::invertImage(data, w, h, sixteenBit); iface.putOriginalImage(i18n("Invert"), data); + delete data; - parentWidget()->setCursor( KCursor::arrowCursor() ); + parentWidget()->setCursor( KCursor::arrowCursor() ); } void ImagePlugin_Core::slotBW() @@ -216,4 +228,41 @@ dlg.exec(); } +void ImagePlugin_Core::slotConvertTo8Bits() +{ + Digikam::ImageIface iface(0, 0); + + if (!iface.originalSixteenBit()) + { + KMessageBox::error(parentWidget(), i18n("This picture already using a depth of 8 bits / color / pixel!")); + return; + } + else + { + if (KMessageBox::warningContinueCancel(parentWidget(), + i18n("Performing this operation will reduce image color quality! " + "Do you want to continue?")) == KMessageBox::Cancel) + return; + } + + parentWidget()->setCursor( KCursor::waitCursor() ); + iface.convertOriginalColorDepth(32); + parentWidget()->setCursor( KCursor::arrowCursor() ); +} + +void ImagePlugin_Core::slotConvertTo16Bits() +{ + Digikam::ImageIface iface(0, 0); + + if (iface.originalSixteenBit()) + { + KMessageBox::error(parentWidget(), i18n("This picture already using a depth of 16 bits / color / pixel!")); + return; + } + + parentWidget()->setCursor( KCursor::waitCursor() ); + iface.convertOriginalColorDepth(64); + parentWidget()->setCursor( KCursor::arrowCursor() ); +} + #include "imageplugin_core.moc" --- trunk/extragear/graphics/digikam/imageplugins/imageplugin_core.h #496360:496361 @@ -57,6 +57,8 @@ KAction *m_sharpenAction; KAction *m_blurAction; KAction *m_colorManagementAction; + KAction *m_convertTo8Bits; + KAction *m_convertTo16Bits; private slots: @@ -75,6 +77,9 @@ void slotColorManagement(); + void slotConvertTo8Bits(); + void slotConvertTo16Bits(); + }; #endif /* IMAGEPLUGIN_CORE_H */ --- trunk/extragear/graphics/digikam/utilities/imageeditor/canvas/dimginterface.cpp #496360:496361 @@ -4,7 +4,7 @@ * Date : 2003-01-15 * Description : * - * Copyright 2003-2005 by Renchi Raju, Gilles Caulier + * Copyright 2003-2006 by Renchi Raju, Gilles Caulier * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General @@ -712,6 +712,14 @@ emit signalModified(true, d->undoMan->anyMoreRedo()); } +void DImgInterface::convertDepth(int depth) +{ + d->undoMan->addAction(new UndoActionIrreversible(this, "Convert Color Depth")); + d->image.convertDepth(depth); + + emit signalModified(true, d->undoMan->anyMoreRedo()); +} + DImg* DImgInterface::getImg() { if (!d->image.isNull()) --- trunk/extragear/graphics/digikam/utilities/imageeditor/canvas/dimginterface.h #496360:496361 @@ -4,7 +4,7 @@ * Date : 2003-01-15 * Description : * - * Copyright 2003-2005 by Renchi Raju, Gilles Caulier + * Copyright 2003-2006 by Renchi Raju, Gilles Caulier * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General @@ -110,6 +110,8 @@ void setBCG(double brightness, double contrast, double gamma); + void convertDepth(int depth); + void getUndoHistory(QStringList &titles); void getRedoHistory(QStringList &titles); --- trunk/extragear/graphics/digikam/utilities/imageeditor/editor/imageiface.cpp #496360:496361 @@ -320,6 +320,11 @@ DImgInterface::instance()->setBCG(brightness, contrast, gamma); } +void ImageIface::convertOriginalColorDepth(int depth) +{ + DImgInterface::instance()->convertDepth(depth); +} + void ImageIface::paint(QPaintDevice* device, int x, int y, int w, int h) { if ( !d->image.isNull() ) --- trunk/extragear/graphics/digikam/utilities/imageeditor/editor/imageiface.h #496360:496361 @@ -99,6 +99,8 @@ void setPreviewBCG(double brightness, double contrast, double gamma, bool overIndicator=false); void setOriginalBCG(double brightness, double contrast, double gamma); + void convertOriginalColorDepth(int depth); + void paint(QPaintDevice* device, int x, int y, int w, int h); // FIXME : remove these methods when all image plugins will be ported to DImg. _______________________________________________ Digikam-devel mailing list [hidden email] https://mail.kde.org/mailman/listinfo/digikam-devel |
Free forum by Nabble | Edit this page |