Commit ced2d226 authored by Cyrille Berger's avatar Cyrille Berger

- add LMS (Long Middle Short Wavelength) colorspace (display doesn't work)

- fix a crash when profile is null in KisColorspaceFactoryRegistry


svn path=/trunk/koffice/; revision=472021
parent 6b5f18a9
......@@ -160,7 +160,11 @@ KisColorSpace * KisColorSpaceFactoryRegistry::getColorSpace(const KisID & csID,
KisColorSpace * KisColorSpaceFactoryRegistry::getColorSpace(const KisID & csID, const KisProfile * profile)
{
return getColorSpace( csID, profile->productName());
if( profile ) {
return getColorSpace( csID, profile->productName());
} else {
return getColorSpace( csID, "");
}
}
......
......@@ -7,6 +7,7 @@ endif
SUBDIRS = rgb_u8 rgb_u16 rgb_f32 \
gray_u8 gray_u16 \
cmyk_u8 cmyk_u16 \
lms_f32 \
$(HALF_SUBDIRS)
#test wetsticky
# Install the desktop file needed to detect the plugin
kde_services_DATA = krita_lms_f32_plugin.desktop
#EXTRA_DIST = $(kritarc_DATA)
INCLUDES = \
-I$(srcdir)/../../sdk \
-I$(srcdir)/../../kritacolor/color_strategy/ \
-I$(srcdir)/../../kritacolor/ \
$(KOFFICE_INCLUDES) \
$(all_includes)
lib_LTLIBRARIES = libkrita_lms_f32.la
libkrita_lms_f32_la_SOURCES = kis_lms_f32_colorspace.cc
libkrita_lms_f32_la_LDFLAGS = $(all_libraries)
libkrita_lms_f32_la_LIBADD = ../../kritacolor/libkritacolor.la
# Install this plugin in the KDE modules directory
kde_module_LTLIBRARIES = krita_lms_f32_plugin.la
# Srcs for the plugin
krita_lms_f32_plugin_la_SOURCES = lms_f32_plugin.cc
noinst_HEADERS = lms_f32_plugin.h kis_lms_f32_colorspace.h
krita_lms_f32_plugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
krita_lms_f32_plugin_la_LIBADD = libkrita_lms_f32.la ../../kritacolor/libkritacolor.la
krita_lms_f32_plugin_la_METASOURCES = AUTO
#METASOURCES = AUTO # XXX: which of the two?
# SUBDIRS = . $(TESTSDIR)
This diff is collapsed.
/*
* Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
* Copyright (c) 2005 Adrian Page <adrian@pagenet.plus.com>
* Copyright (c) 2005 Cyrille Berger <cberger@cberger.net>
*
* 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_STRATEGY_COLORSPACE_LMS_F32_H_
#define KIS_STRATEGY_COLORSPACE_LMS_F32_H_
#include <qcolor.h>
#include <klocale.h>
#include <koffice_export.h>
#include "kis_global.h"
#include "kis_f32_base_colorspace.h"
#include "kis_pixel.h"
class KisColorSpaceFactoryRegistry;
class KRITATOOL_EXPORT KisLmsF32ColorSpace : public KisF32BaseColorSpace {
public:
KisLmsF32ColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p);
virtual ~KisLmsF32ColorSpace();
public:
void setPixel(Q_UINT8 *pixel, float longWave, float middleWave, float shortWave, float alpha) const;
void getPixel(const Q_UINT8 *pixel, float *longWave, float *middleWave, float *shortWave, float *alpha) const;
virtual void fromQColor(const QColor& c, Q_UINT8 *dst);
virtual void fromQColor(const QColor& c, Q_UINT8 opacity, Q_UINT8 *dst);
virtual void toQColor(const Q_UINT8 *src, QColor *c);
virtual void toQColor(const Q_UINT8 *src, QColor *c, Q_UINT8 *opacity);
//XXX: KisPixel(RO) does not work with this colourspace as it only handles 8-bit channels.
virtual KisPixelRO toKisPixelRO(const Q_UINT8 *src)
{ return KisPixelRO (src, src + PIXEL_ALPHA * sizeof(float), this); }
virtual KisPixel toKisPixel(Q_UINT8 *src)
{ return KisPixel (src, src + PIXEL_ALPHA * sizeof(float), this); }
virtual Q_INT8 difference(const Q_UINT8 *src1, const Q_UINT8 *src2);
virtual void mixColors(const Q_UINT8 **colors, const Q_UINT8 *weights, Q_UINT32 nColors, Q_UINT8 *dst) const;
virtual QValueVector<KisChannelInfo *> channels() const;
virtual bool hasAlpha() const;
virtual Q_INT32 nChannels() const;
virtual Q_INT32 nColorChannels() const;
virtual Q_INT32 pixelSize() const;
virtual QImage convertToQImage(const Q_UINT8 *data, Q_INT32 width, Q_INT32 height,
KisProfile * dstProfile,
Q_INT32 renderingIntent,
float exposure = 0.0f);
virtual KisCompositeOpList userVisiblecompositeOps() const;
protected:
virtual void bitBlt(Q_UINT8 *dst,
Q_INT32 dstRowStride,
const Q_UINT8 *src,
Q_INT32 srcRowStride,
const Q_UINT8 *srcAlphaMask,
Q_INT32 maskRowStride,
Q_UINT8 opacity,
Q_INT32 rows,
Q_INT32 cols,
const KisCompositeOp& op);
void compositeOver(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *mask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 columns, float opacity);
void compositeErase(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *mask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 columns, float opacity);
void compositeCopy(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *mask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 columns, float opacity);
private:
inline Q_UINT8 computeRed(float l, float m, float s) const
{
return FLOAT_TO_UINT8(4.4679*l - 3.58738*m + 0.1193*s);
}
inline Q_UINT8 computeGreen(float l, float m, float s) const
{
return FLOAT_TO_UINT8(-1.2186*l + 2.3809*m - 0.1624*s);
}
inline Q_UINT8 computeBlue(float l, float m, float s) const
{
return FLOAT_TO_UINT8(0.0497*l - 0.2439*m + 1.2045*s);
}
inline float computeLong(Q_UINT8 r, Q_UINT8 g, Q_UINT8 b) const
{
return 0.3811*UINT8_TO_FLOAT(r) + 0.5783*UINT8_TO_FLOAT(g) + 0.0402*UINT8_TO_FLOAT(b);
}
inline float computeMiddle(Q_UINT8 r, Q_UINT8 g, Q_UINT8 b) const
{
return 0.1967*UINT8_TO_FLOAT(r) + 0.7244*UINT8_TO_FLOAT(g) + 0.0782*UINT8_TO_FLOAT(b);
}
inline float computeShort(Q_UINT8 r, Q_UINT8 g, Q_UINT8 b) const
{
return 0.0241*UINT8_TO_FLOAT(r) + 0.1288*UINT8_TO_FLOAT(g) + 0.8444*UINT8_TO_FLOAT(b);
}
friend class KisLmsF32ColorSpaceTester;
static const Q_UINT8 PIXEL_LONGWAVE = 0;
static const Q_UINT8 PIXEL_MIDDLEWAVE = 1;
static const Q_UINT8 PIXEL_SHORTWAVE = 2;
static const Q_UINT8 PIXEL_ALPHA = 3;
struct Pixel {
float longWave;
float middleWave;
float shortWave;
float alpha;
};
};
class KisLmsF32ColorSpaceFactory : public KisColorSpaceFactory
{
public:
/**
* Krita definition for use in .kra files and internally: unchanging name +
* i18n'able description.
*/
virtual KisID id() const { return KisID("LMSAF32", i18n("LMS/Alpha cone space (32-bit float/channel)")); };
/**
* lcms colorspace type definition.
*/
virtual Q_UINT32 colorSpaceType() { return 0; }; // FIXME: lcms do not support LMS cone space
virtual icColorSpaceSignature colorSpaceSignature() { return icMaxEnumData; };
virtual KisColorSpace *createColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p) { return new KisLmsF32ColorSpace(parent, p); };
virtual QString defaultProfile() { return "sRGB built-in - (lcms internal)"; };
};
#endif // KIS_STRATEGY_COLORSPACE_LMS_F32_H_
[Desktop Entry]
Encoding=UTF-8
Name=LMS Color Model (32-bit float)
Comment=Color model for LMS cone space (Long Middle and Short wavelengths)
ServiceTypes=Krita/ColorSpace
Type=Service
X-KDE-Library=krita_lms_f32_plugin
X-KDE-Version=2
/*
* lms_f32_plugin.cc -- Part of Krita
*
* Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org)
* Copyright (c) 2005 Adrian Page <adrian@pagenet.plus.com>
* Copyright (c) 2005 Cyrille Berger <cberger@cberger.net>
*
* 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 <kinstance.h>
#include <kgenericfactory.h>
#include <kdebug.h>
#include <kis_global.h>
#include <kis_colorspace_factory_registry.h>
#include <kis_basic_histogram_producers.h>
#include "lms_f32_plugin.h"
#include "kis_lms_f32_colorspace.h"
typedef KGenericFactory<LMSF32Plugin> LMSF32PluginFactory;
K_EXPORT_COMPONENT_FACTORY( krita_lms_f32_plugin, LMSF32PluginFactory( "krita" ) )
LMSF32Plugin::LMSF32Plugin(QObject *parent, const char *name, const QStringList &)
: KParts::Plugin(parent, name)
{
setInstance(LMSF32PluginFactory::instance());
kdDebug(DBG_AREA_PLUGINS) << "32-bit float LMS Color model plugin. Class: "
<< className()
<< ", Parent: "
<< parent -> className()
<< "\n";
if ( parent->inherits("KisColorSpaceFactoryRegistry") )
{
KisColorSpaceFactoryRegistry * f = dynamic_cast<KisColorSpaceFactoryRegistry*>(parent);
KisColorSpace * colorSpaceLMSF32 = new KisLmsF32ColorSpace(f, 0);
KisColorSpaceFactory * csf = new KisLmsF32ColorSpaceFactory();
f -> add(csf);
KisHistogramProducerFactoryRegistry::instance() -> add(
new KisBasicHistogramProducerFactory<KisBasicF32HistogramProducer>
(KisID("LMSF32HISTO", i18n("Float32 Histogram")), colorSpaceLMSF32) );
}
}
LMSF32Plugin::~LMSF32Plugin()
{
}
#include "lms_f32_plugin.moc"
/*
* Copyright (c) 2003 Boudewijn Rempt (boud@valdyas.org)
* Copyright (c) 2005 Cyrille Berger <cberger@cberger.net>
*
* 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 LMS_F32_PLUGIN_H_
#define LMS_F32_PLUGIN_H_
#include <kparts/plugin.h>
/**
* A plugin wrapper around the LMS F32 colour space strategy.
*/
class LMSF32Plugin : public KParts::Plugin
{
Q_OBJECT
public:
LMSF32Plugin(QObject *parent, const char *name, const QStringList &);
virtual ~LMSF32Plugin();
};
#endif // LMS_F32_PLUGIN_H_
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui library="krita_lms_f32_plugin" version="1">
<Menu name="Image"><text>&amp;Image</text>
<Menu name="Mode"><text>&amp;Mode</text>
<Action name="convert to RGB(A) (32-bit float)"/>
</Menu>
</Menu>
</kpartgui>
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