Commit aef19efb authored by Gilles Caulier's avatar Gilles Caulier 🗼
Browse files

add new BQM tool to auto-crop images

parent fc062c2f
......@@ -34,7 +34,7 @@ SET(DIGIKAM_RELEASE_DATE "2013-04-07")
# "-beta3" : beta3 release.
# "-rc" : release candidate.
# "" : final release. Can be used in production.
SET(DIGIKAM_SUFFIX_VERSION "-git")
SET(DIGIKAM_SUFFIX_VERSION "-beta1")
# ==================================================================================================
# Set env. variables accordingly.
......
*****************************************************************************************************
digiKam 3.2.0 - Release date: 2013-04-07
digiKam 3.2.0-beta1 - Release date: 2013-04-07
NEW FEATURES:
AlbumGUI : New "Table-View" view mode dedictaed to show album items in a list view.
General : Remove internal clapack library code. Set only an optional and external dependency to eigen3.
AlbumGUI : New "Table-View" view mode dedictaed to show album items in a list view.
General : Remove internal clapack library code. Set only an optional and external dependency to eigen3.
General : New tool to auto-crop image based on black hole borders detection.
BUGFIXES FROM KDE BUGZILLA (alias B.K.O | http://bugs.kde.org):
......
......@@ -29,6 +29,7 @@
#include <QRect>
#include <QWidget>
#include <QGridLayout>
#include <QCheckBox>
// KDE includes
......@@ -43,6 +44,7 @@
// Local includes
#include "autocrop.h"
#include "dimg.h"
#include "dimgbuiltinfilter.h"
......@@ -54,6 +56,7 @@ class Crop::Private
public:
Private() :
autoCrop(0),
heightInput(0),
widthInput(0),
xInput(0),
......@@ -63,6 +66,8 @@ public:
public:
QCheckBox* autoCrop;
RIntNumInput* heightInput;
RIntNumInput* widthInput;
RIntNumInput* xInput;
......@@ -74,7 +79,7 @@ Crop::Crop(QObject* const parent)
d(new Private)
{
setToolTitle(i18n("Crop"));
setToolDescription(i18n("Crop images with a customized region."));
setToolDescription(i18n("Crop images to a region."));
setToolIconName("transform-crop");
}
......@@ -89,6 +94,10 @@ void Crop::registerSettingsWidget()
// -------------------------------------------------------------
d->autoCrop = new QCheckBox(i18n("Auto-Crop"), m_settingsWidget);
d->autoCrop->setWhatsThis(i18n("Compute automatically crop area settings by a parse of "
"black hole image borders."));
QLabel* const positionLabel = new QLabel(i18n("Position:"), m_settingsWidget);
positionLabel->setAlignment(Qt::AlignLeft|Qt::AlignVCenter);
......@@ -124,17 +133,26 @@ void Crop::registerSettingsWidget()
// -------------------------------------------------------------
QGridLayout* const mainLayout = new QGridLayout(m_settingsWidget);
mainLayout->addWidget(positionLabel, 0, 0, 1, 1);
mainLayout->addWidget(d->xInput, 0, 1, 1, 3);
mainLayout->addWidget(d->yInput, 1, 1, 1, 3);
mainLayout->addWidget(sizeLabel, 2, 0, 1, 1);
mainLayout->addWidget(d->widthInput, 2, 1, 1, 3);
mainLayout->addWidget(d->heightInput, 3, 1, 1, 3);
mainLayout->addWidget(new QLabel(m_settingsWidget), 4, 1, 1, 3);
mainLayout->setRowStretch(4, 10);
mainLayout->addWidget(d->autoCrop, 0, 0, 1, 1);
mainLayout->addWidget(positionLabel, 1, 0, 1, 1);
mainLayout->addWidget(d->xInput, 1, 1, 1, 3);
mainLayout->addWidget(d->yInput, 2, 1, 1, 3);
mainLayout->addWidget(sizeLabel, 3, 0, 1, 1);
mainLayout->addWidget(d->widthInput, 3, 1, 1, 3);
mainLayout->addWidget(d->heightInput, 4, 1, 1, 3);
mainLayout->addWidget(new QLabel(m_settingsWidget), 5, 1, 1, 3);
mainLayout->setRowStretch(5, 10);
mainLayout->setMargin(KDialog::spacingHint());
mainLayout->setSpacing(KDialog::spacingHint());
// -------------------------------------------------------------
connect(d->autoCrop, SIGNAL(clicked(bool)),
this, SLOT(slotDisableParameters(bool)));
connect(this, SIGNAL(signalAutoCrop()),
this, SLOT(slotSettingsChanged()));
connect(d->xInput, SIGNAL(valueChanged(int)),
this, SLOT(slotSettingsChanged()));
......@@ -150,6 +168,17 @@ void Crop::registerSettingsWidget()
BatchTool::registerSettingsWidget();
}
void Crop::slotDisableParameters(bool b)
{
d->xInput->setDisabled(b);
d->yInput->setDisabled(b);
d->widthInput->setDisabled(b);
d->heightInput->setDisabled(b);
if (b)
emit signalAutoCrop();
}
BatchToolSettings Crop::defaultSettings()
{
BatchToolSettings settings;
......@@ -157,6 +186,7 @@ BatchToolSettings Crop::defaultSettings()
settings.insert("yInput", 50);
settings.insert("widthInput", 800);
settings.insert("heightInput", 600);
settings.insert("AutoCrop", false);
return settings;
}
......@@ -166,6 +196,7 @@ void Crop::slotAssignSettings2Widget()
d->yInput->setValue(settings()["yInput"].toInt());
d->widthInput->setValue(settings()["widthInput"].toInt());
d->heightInput->setValue(settings()["heightInput"].toInt());
d->autoCrop->setChecked(settings()["AutoCrop"].toBool());
}
void Crop::slotSettingsChanged()
......@@ -175,6 +206,7 @@ void Crop::slotSettingsChanged()
settings.insert("yInput", d->yInput->value());
settings.insert("widthInput", d->widthInput->value());
settings.insert("heightInput", d->heightInput->value());
settings.insert("AutoCrop", d->autoCrop->isChecked());
BatchTool::slotSettingsChanged(settings);
}
......@@ -184,6 +216,7 @@ bool Crop::toolOperations()
int yInput = settings()["yInput"].toInt();
int widthInput = settings()["widthInput"].toInt();
int heightInput = settings()["heightInput"].toInt();
bool autoCrop = settings()["AutoCrop"].toBool();
if (!loadToDImg())
{
......@@ -192,6 +225,13 @@ bool Crop::toolOperations()
QRect rect(xInput, yInput, widthInput, heightInput);
if (autoCrop)
{
AutoCrop ac(&image());
ac.startFilterDirectly();
rect = ac.autoInnerCrop();
}
if (!rect.isValid())
{
return false;
......
......@@ -46,10 +46,15 @@ public:
void registerSettingsWidget();
Q_SIGNALS:
void signalAutoCrop();
private Q_SLOTS:
void slotAssignSettings2Widget();
void slotSettingsChanged();
void slotDisableParameters(bool);
private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment