[kde-doc-english] extragear/graphics/kphotoalbum
Miika Turkia
thebro at luukku.com
Sun Jan 24 10:08:41 CET 2010
SVN commit 1079369 by mturkia:
GUI: Added checkboxes for display filters to view which ones are selected.
Added check that color depth is enough for each filter.
M +6 -0 ChangeLog
M +23 -4 Viewer/ImageDisplay.cpp
M +5 -4 Viewer/ImageDisplay.h
M +42 -4 Viewer/ViewerWidget.cpp
M +2 -0 Viewer/ViewerWidget.h
--- trunk/extragear/graphics/kphotoalbum/ChangeLog #1079368:1079369
@@ -1,3 +1,9 @@
+2010-01-24 Miika Turkia <theBro at luukku.com>
+
+ * GUI: Added checkboxes for display filters to view which ones are
+ selected.
+ * Added check that color depth is enough for each filter.
+
2010-01-23 Miika Turkia <theBro at luukku.com>
* Minor tweak on HTMLGenerator theme darkJS to highlight displayed
--- trunk/extragear/graphics/kphotoalbum/Viewer/ImageDisplay.cpp #1079368:1079369
@@ -22,6 +22,7 @@
#include <QPaintEvent>
#include <QResizeEvent>
#include <QMouseEvent>
+#include <KMessageBox>
#include <klocale.h>
#include "Settings/SettingsData.h"
#include "Viewer/ViewHandler.h"
@@ -336,15 +337,21 @@
update();
}
-void Viewer::ImageDisplay::filterMono()
+int Viewer::ImageDisplay::filterMono()
{
_croppedAndScaledImg = _croppedAndScaledImg.convertToFormat(_croppedAndScaledImg.Format_Mono);
update();
+ return 0;
}
// I can't believe there isn't a standard conversion for this??? -- WH
-void Viewer::ImageDisplay::filterBW()
+int Viewer::ImageDisplay::filterBW()
{
+ if (_croppedAndScaledImg.depth() < 32) {
+ KMessageBox::error( this, i18n("Insufficient color depth for this filter"));
+ return -1;
+ }
+
for (int y = 0; y < _croppedAndScaledImg.height(); ++y) {
for (int x = 0; x < _croppedAndScaledImg.width(); ++x) {
int pixel = _croppedAndScaledImg.pixel(x, y);
@@ -354,15 +361,21 @@
}
}
update();
+ return 0;
}
-void Viewer::ImageDisplay::filterContrastStretch()
+int Viewer::ImageDisplay::filterContrastStretch()
{
int redMin, redMax, greenMin, greenMax, blueMin, blueMax;
redMin = greenMin = blueMin = 255;
redMax = greenMax = blueMax = 0;
+ if (_croppedAndScaledImg.depth() < 32) {
+ KMessageBox::error( this, i18n("Insufficient color depth for this filter"));
+ return -1;
+ }
+
// Look for minimum and maximum intensities within each color channel
for (int y = 0; y < _croppedAndScaledImg.height(); ++y) {
for (int x = 0; x < _croppedAndScaledImg.width(); ++x) {
@@ -408,9 +421,10 @@
}
}
update();
+ return 0;
}
-void Viewer::ImageDisplay::filterHistogramEqualization()
+int Viewer::ImageDisplay::filterHistogramEqualization()
{
int width, height;
float R_histogram[256];
@@ -418,6 +432,10 @@
float B_histogram[256];
float d;
+ if (_croppedAndScaledImg.depth() < 32) {
+ KMessageBox::error( this, i18n("Insufficient color depth for this filter"));
+ return -1;
+ }
memset(R_histogram, 0, sizeof(R_histogram));
memset(G_histogram, 0, sizeof(G_histogram));
memset(B_histogram, 0, sizeof(B_histogram));
@@ -465,6 +483,7 @@
}
}
update();
+ return 0;
}
void Viewer::ImageDisplay::updateZoomCaption() {
--- trunk/extragear/graphics/kphotoalbum/Viewer/ImageDisplay.h #1079368:1079369
@@ -60,10 +60,11 @@
void setImageList( const QStringList& list );
void filterNone();
- void filterMono();
- void filterBW();
- void filterContrastStretch();
- void filterHistogramEqualization();
+ void filterSelected();
+ int filterMono();
+ int filterBW();
+ int filterContrastStretch();
+ int filterHistogramEqualization();
public slots:
void zoomIn();
--- trunk/extragear/graphics/kphotoalbum/Viewer/ViewerWidget.cpp #1079368:1079369
@@ -488,6 +488,7 @@
void Viewer::ViewerWidget::showNextN(int n)
{
+ filterNone();
if ( _display == _videoDisplay ) {
_videoPlayerStoppedManually = true;
_videoDisplay->stop();
@@ -891,34 +892,67 @@
{
if ( _display == _imageDisplay ) {
_imageDisplay->filterNone();
+ _filterMono->setChecked( false );
+ _filterBW->setChecked( false );
+ _filterContrastStretch->setChecked( false );
+ _filterHistogramEqualization->setChecked( false );
}
}
+void Viewer::ViewerWidget::filterSelected()
+{
+ // The filters that drop bit depth below 32 should be the last ones
+ // so that filters requiring more bit depth are processed first
+ if ( _display == _imageDisplay ) {
+ _imageDisplay->filterNone();
+ if (_filterBW->isChecked())
+ _imageDisplay->filterBW();
+ if (_filterContrastStretch->isChecked())
+ _imageDisplay->filterContrastStretch();
+ if (_filterHistogramEqualization->isChecked())
+ _imageDisplay->filterHistogramEqualization();
+ if (_filterMono->isChecked())
+ _imageDisplay->filterMono();
+ }
+}
+
void Viewer::ViewerWidget::filterBW()
{
if ( _display == _imageDisplay ) {
- _imageDisplay->filterBW();
+ if ( _filterBW->isChecked() )
+ _filterBW->setChecked( !_imageDisplay->filterBW());
+ else
+ filterSelected();
}
}
void Viewer::ViewerWidget::filterContrastStretch()
{
if ( _display == _imageDisplay ) {
- _imageDisplay->filterContrastStretch();
+ if (_filterContrastStretch->isChecked())
+ _filterContrastStretch->setChecked( !_imageDisplay->filterContrastStretch() );
+ else
+ filterSelected();
}
}
void Viewer::ViewerWidget::filterHistogramEqualization()
{
if ( _display == _imageDisplay ) {
- _imageDisplay->filterHistogramEqualization();
+ if ( _filterHistogramEqualization->isChecked() )
+ _filterHistogramEqualization->setChecked( !_imageDisplay->filterHistogramEqualization() );
+ else
+ filterSelected();
}
}
void Viewer::ViewerWidget::filterMono()
{
if ( _display == _imageDisplay ) {
- _imageDisplay->filterMono();
+ if ( _filterMono->isChecked() )
+ _filterMono->setChecked( !_imageDisplay->filterMono() );
+ else
+ filterSelected();
}
}
@@ -1280,18 +1314,22 @@
_filterBW = _actions->addAction( QString::fromLatin1("filter-bw"), this, SLOT( filterBW() ) );
_filterBW->setText( i18n("Apply Grayscale Filter") );
+ _filterBW->setCheckable( true );
_filterMenu->addAction( _filterBW );
_filterContrastStretch = _actions->addAction( QString::fromLatin1("filter-cs"), this, SLOT( filterContrastStretch() ) );
_filterContrastStretch->setText( i18n("Apply Contrast Stretching Filter") );
+ _filterContrastStretch->setCheckable( true );
_filterMenu->addAction( _filterContrastStretch );
_filterHistogramEqualization = _actions->addAction( QString::fromLatin1("filter-he"), this, SLOT( filterHistogramEqualization() ) );
_filterHistogramEqualization->setText( i18n("Apply Histogram Equalization Filter") );
+ _filterHistogramEqualization->setCheckable( true );
_filterMenu->addAction( _filterHistogramEqualization );
_filterMono = _actions->addAction( QString::fromLatin1("filter-mono"), this, SLOT( filterMono() ) );
_filterMono->setText( i18n("Apply Monochrome Filter") );
+ _filterMono->setCheckable( true );
_filterMenu->addAction( _filterMono );
_popup->addMenu( _filterMenu );
--- trunk/extragear/graphics/kphotoalbum/Viewer/ViewerWidget.h #1079368:1079369
@@ -130,6 +130,7 @@
void slotSlideShowSlower();
void editImage();
void filterNone();
+ void filterSelected();
void filterBW();
void filterContrastStretch();
void filterHistogramEqualization();
@@ -166,6 +167,7 @@
KAction* _slideShowRunSlower;
KAction* _setStackHead;
KAction* _filterNone;
+ KAction* _filterSelected;
KAction* _filterBW;
KAction* _filterContrastStretch;
KAction* _filterHistogramEqualization;
More information about the kde-doc-english
mailing list