Commit 4640ea84 authored by Cyrille Berger's avatar Cyrille Berger

initial port of the level filter

svn path=/trunk/koffice/; revision=849672
parents 4a82e69c 62059e77
......@@ -21,5 +21,6 @@ add_subdirectory( sobelfilter )
add_subdirectory( unsharp )
add_subdirectory( wavefilter )
add_subdirectory( cubismfilter )
add_subdirectory( levelfilter )
message(STATUS "Filters that still need to be fixed: CImg, bumpmap")
set(kritalevelfilter_PART_SRCS
levelfilter.cc
kis_level_filter.cc
kgradientslider.cc
)
kde4_add_ui_files(kritalevelfilter_PART_SRCS
wdg_level.ui
)
kde4_add_plugin(kritalevelfilter ${kritalevelfilter_PART_SRCS})
target_link_libraries(kritalevelfilter kritaui)
install(TARGETS kritalevelfilter DESTINATION ${PLUGIN_INSTALL_DIR})
########### install files ###############
install( FILES kritalevelfilter.desktop DESTINATION ${SERVICES_INSTALL_DIR})
kde_services_DATA = kritalevelfilter.desktop
INCLUDES = -I$(srcdir)/../../../sdk \
-I$(srcdir)/../../../core \
-I$(srcdir)/../../../kritacolor/ \
-I$(srcdir)/../../../ui \
$(KOFFICE_INCLUDES) \
$(all_includes)
kritalevelfilter_la_SOURCES = levelfilter.cc \
wdg_level.ui \
kis_level_filter.cc \
kgradientslider.cc
noinst_HEADERS = levelfilter.h \
kis_level_filter.h \
kgradientslider.h
kritalevelfilter_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
kritalevelfilter_la_LIBADD = ../../../libkritacommon.la
kde_module_LTLIBRARIES = kritalevelfilter.la
kritalevelfilter_la_METASOURCES = AUTO
This diff is collapsed.
/*
* This file is part of Krita
*
* Copyright (c) 2006 Frederic Coiffier <fcoiffie@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KGRADIENTSLIDER_H
#define KGRADIENTSLIDER_H
// Qt includes.
#include <qwidget.h>
#include <qcolor.h>
#include <qlist.h>
#include <qpair.h>
class KGradientSlider : public QWidget
{
Q_OBJECT
typedef enum {
BlackCursor,
GammaCursor,
WhiteCursor
} eCursor;
public:
KGradientSlider(QWidget *parent = 0);
virtual ~KGradientSlider();
public slots:
void modifyBlack(int);
void modifyWhite(int);
void modifyGamma(double);
signals:
void modifiedBlack(int);
void modifiedWhite(int);
void modifiedGamma(double);
protected:
void paintEvent(QPaintEvent *);
void mousePressEvent (QMouseEvent * e);
void mouseReleaseEvent ( QMouseEvent * e );
void mouseMoveEvent ( QMouseEvent * e );
void leaveEvent ( QEvent * );
public:
void enableGamma(bool b);
double getGamma(void);
private:
unsigned int m_leftmost;
unsigned int m_rightmost;
eCursor m_grab_cursor;
unsigned int m_grab_index;
bool m_dragging;
unsigned int m_blackcursor;
unsigned int m_whitecursor;
unsigned int m_gammacursor;
bool m_gammaEnabled;
double m_gamma;
};
#endif /* KGRADIENTSLIDER_H */
This diff is collapsed.
/*
* This file is part of Krita
*
* Copyright (c) 2006 Frederic Coiffier <fcoiffie@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _KIS_LEVEL_FILTER_H_
#define _KIS_LEVEL_FILTER_H_
#include "filter/kis_filter.h"
#include "filter/kis_filter_configuration.h"
#include "filter/kis_filter_config_widget.h"
#include "ui_wdg_level.h"
class WdgLevel;
class QWidget;
class KisColorAdjustment;
class KisHistogram;
#if 0
class KisLevelFilterConfiguration : public KisFilterConfiguration {
public:
KisLevelFilterConfiguration();
virtual ~KisLevelFilterConfiguration();
virtual void fromXML( const QString& );
virtual QString toString();
public:
Q_UINT8 blackvalue, whitevalue;
double gammavalue;
Q_UINT16 outblackvalue, outwhitevalue;
KisColorAdjustment * m_adjustment;
};
#endif
/**
* This class affect Intensity Y of the image
*/
class KisLevelFilter : public KisFilter
{
public:
KisLevelFilter();
~KisLevelFilter();
public:
// virtual KisFilterConfiguration* factoryConfiguration(const KisPaintDeviceSP) const;
virtual KisFilterConfigWidget * createConfigurationWidget(QWidget* parent, KisPaintDeviceSP dev);
virtual void process(KisConstProcessingInformation src,
KisProcessingInformation dst,
const QSize& size,
const KisFilterConfiguration* config,
KoUpdater* progressUpdater
) const;
static inline KoID id() { return KoID("levels", i18n("Levels")); };
virtual bool workWith(KoColorSpace* cs) const;
};
class KisLevelConfigWidget : public KisFilterConfigWidget {
Q_OBJECT
public:
KisLevelConfigWidget(QWidget * parent, KisPaintDeviceSP dev);
virtual ~KisLevelConfigWidget();
virtual KisFilterConfiguration* configuration() const;
void setConfiguration( KisFilterConfiguration * config );
Ui::WdgLevel m_page;
protected slots:
void drawHistogram(bool logarithmic = false);
protected:
KisHistogram *histogram;
bool m_histlog;
};
#endif
[Desktop Entry]
Name=Levels
Name[bg]=Нива
Name[br]=Liveoù
Name[ca]=Nivells
Name[da]=Niveauer
Name[de]=Stufen
Name[el]=Επίπεδα
Name[eo]=Niveloj
Name[es]=Niveles
Name[et]=Tasemed
Name[fa]=سطوح
Name[fy]=Nivo's
Name[hr]=Razine
Name[hu]=Szintek
Name[it]=Livelli
Name[ja]=レベル
Name[km]=កម្រិត
Name[lt]=Lygiai
Name[nb]=Nivåer
Name[nds]=Stopen
Name[ne]=स्तर
Name[nl]=Niveaus
Name[pl]=Poziomy
Name[pt]=Níveis
Name[pt_BR]=Níveis
Name[ru]=Уровни
Name[se]=Dásit
Name[sk]=Úrovne
Name[sl]=Ravni
Name[sr]=Нивои
Name[sr@Latn]=Nivoi
Name[sv]=Nivåer
Name[uk]=Рівні
Name[zh_TW]=等級
Comment=Levels
Comment[bg]=Нива
Comment[br]=Liveoù
Comment[ca]=Nivells
Comment[da]=Niveauer
Comment[de]=Stufen
Comment[el]=Επίπεδα
Comment[eo]=Niveloj
Comment[es]=Niveles
Comment[et]=Tasemed
Comment[fa]=سطوح
Comment[fy]=Nivo's
Comment[hr]=Razine
Comment[hu]=Szintek
Comment[it]=Livelli
Comment[ja]=レベル
Comment[km]=កម្រិត
Comment[lt]=Lygiai
Comment[nb]=Nivåer
Comment[nds]=Stopen
Comment[ne]=स्तर
Comment[nl]=Niveaus
Comment[pl]=Poziomy
Comment[pt]=Níveis
Comment[pt_BR]=Níveis
Comment[ru]=Уровни
Comment[se]=Dásit
Comment[sk]=Úrovne
Comment[sl]=Ravni
Comment[sr]=Нивои
Comment[sr@Latn]=Nivoi
Comment[sv]=Nivåer
Comment[uk]=Рівні
Comment[zh_TW]=等級
ServiceTypes=Krita/Filter
Type=Service
X-KDE-Library=kritalevelfilter
X-Krita-Version=2
/*
* This file is part of Krita
*
* Copyright (c) 2006 Frederic Coiffier <fcoiffie@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "levelfilter.h"
#include <kgenericfactory.h>
#include "kis_level_filter.h"
#include "filter/kis_filter_registry.h"
typedef KGenericFactory<LevelFilter> LevelFilterFactory;
K_EXPORT_COMPONENT_FACTORY( kritalevelfilter, LevelFilterFactory( "krita" ) )
LevelFilter::LevelFilter(QObject *parent, const QStringList &)
: KParts::Plugin(parent)
{
setComponentData(LevelFilterFactory::componentData());
if (parent->inherits("KisFilterRegistry")) {
KisFilterRegistry * manager = dynamic_cast<KisFilterRegistry *>(parent);
manager->add(new KisLevelFilter());
}
}
LevelFilter::~LevelFilter()
{
}
/*
* This file is part of Krita
*
* Copyright (c) 2006 Frederic Coiffier <fcoiffie@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef LEVEL_H
#define LEVEL_H
#include <kparts/plugin.h>
class KisColorSpace;
class KisColorAdjustment;
class LevelFilter : public KParts::Plugin
{
public:
LevelFilter(QObject *parent, const QStringList &);
virtual ~LevelFilter();
};
#endif
<ui version="4.0" >
<class>WdgLevel</class>
<widget class="QWidget" name="WdgLevel" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>285</width>
<height>479</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="MinimumExpanding" hsizetype="MinimumExpanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>32767</width>
<height>32767</height>
</size>
</property>
<property name="windowTitle" >
<string>Levels</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<item row="0" column="0" >
<widget class="QCheckBox" name="chkLogarithmic" >
<property name="text" >
<string>Logarithmic</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="textLabel2" >
<property name="text" >
<string>&lt;b>Input levels&lt;/b></string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0" >
<layout class="QVBoxLayout" >
<item>
<widget class="QLabel" name="histview" >
<property name="minimumSize" >
<size>
<width>256</width>
<height>256</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>256</width>
<height>256</height>
</size>
</property>
<property name="scaledContents" >
<bool>true</bool>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" >
<item>
<widget class="KGradientSlider" native="1" name="ingradient" >
<property name="minimumSize" >
<size>
<width>256</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QSpinBox" name="blackspin" >
<property name="buttonSymbols" >
<enum>QAbstractSpinBox::PlusMinus</enum>
</property>
<property name="maximum" >
<number>255</number>
</property>
</widget>
</item>
<item>
<spacer name="spacer5" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>25</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="gammaspin" >
<property name="text" >
<string>1.0</string>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="spacer6" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>25</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="whitespin" >
<property name="buttonSymbols" >
<enum>QAbstractSpinBox::PlusMinus</enum>
</property>
<property name="maximum" >
<number>255</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="textLabel3" >
<property name="text" >
<string>&lt;b>Output levels&lt;/b></string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" >
<item>
<widget class="KGradientSlider" native="1" name="outgradient" >
<property name="minimumSize" >
<size>
<width>256</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QSpinBox" name="outblackspin" >
<property name="buttonSymbols" >
<enum>QAbstractSpinBox::PlusMinus</enum>
</property>
<property name="maximum" >
<number>255</number>
</property>
</widget>
</item>
<item>
<spacer name="spacer3" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>50</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="outwhitespin" >
<property name="buttonSymbols" >
<enum>QAbstractSpinBox::PlusMinus</enum>
</property>
<property name="maximum" >
<number>255</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item row="2" column="1" >
<spacer name="spacer5_2" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>21</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0" >
<spacer name="spacer6_2" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >