summaryrefslogtreecommitdiffstats
path: root/krita/colorspaces/lms_f32
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
commit8362bf63dea22bbf6736609b0f49c152f975eb63 (patch)
tree0eea3928e39e50fae91d4e68b21b1e6cbae25604 /krita/colorspaces/lms_f32
downloadkoffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz
koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'krita/colorspaces/lms_f32')
-rw-r--r--krita/colorspaces/lms_f32/Makefile.am28
-rw-r--r--krita/colorspaces/lms_f32/kis_lms_f32_colorspace.cc385
-rw-r--r--krita/colorspaces/lms_f32/kis_lms_f32_colorspace.h157
-rw-r--r--krita/colorspaces/lms_f32/krita_lms_f32_plugin.desktop77
-rw-r--r--krita/colorspaces/lms_f32/lms_f32_plugin.cc64
-rw-r--r--krita/colorspaces/lms_f32/lms_f32_plugin.h39
-rw-r--r--krita/colorspaces/lms_f32/lms_f32_plugin.rc9
7 files changed, 759 insertions, 0 deletions
diff --git a/krita/colorspaces/lms_f32/Makefile.am b/krita/colorspaces/lms_f32/Makefile.am
new file mode 100644
index 00000000..f34e9a20
--- /dev/null
+++ b/krita/colorspaces/lms_f32/Makefile.am
@@ -0,0 +1,28 @@
+# Install the desktop file needed to detect the plugin
+kde_services_DATA = krita_lms_f32_plugin.desktop
+
+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
+
diff --git a/krita/colorspaces/lms_f32/kis_lms_f32_colorspace.cc b/krita/colorspaces/lms_f32/kis_lms_f32_colorspace.cc
new file mode 100644
index 00000000..0c8b91bf
--- /dev/null
+++ b/krita/colorspaces/lms_f32/kis_lms_f32_colorspace.cc
@@ -0,0 +1,385 @@
+/*
+ * Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
+ * 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 <config.h>
+#include <limits.h>
+#include <stdlib.h>
+#include LCMS_HEADER
+
+#include <qimage.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+
+#include "kis_lms_f32_colorspace.h"
+#include "kis_color_conversions.h"
+
+namespace {
+ const Q_INT32 MAX_CHANNEL_LMS = 3;
+ const Q_INT32 MAX_CHANNEL_LMSA = 4;
+}
+
+#include "kis_integer_maths.h"
+
+#define FLOAT_MAX 1.0f //temp
+
+#define EPSILON 1e-6
+
+// FIXME: lcms doesn't support 32-bit float
+#define F32_LCMS_TYPE TYPE_BGRA_16
+
+// disable the lcms handling by setting profile=0
+KisLmsF32ColorSpace::KisLmsF32ColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile */*p*/) :
+ KisF32BaseColorSpace(KisID("LMSAF32", i18n("LMS (32-bit float/channel)")), F32_LCMS_TYPE, icSig3colorData, parent, 0)
+{
+ m_channels.push_back(new KisChannelInfo(i18n("Long"), i18n("L"), PIXEL_LONGWAVE * sizeof(float), KisChannelInfo::COLOR, KisChannelInfo::FLOAT32, sizeof(float)));
+ m_channels.push_back(new KisChannelInfo(i18n("Middle"), i18n("M"), PIXEL_MIDDLEWAVE * sizeof(float), KisChannelInfo::COLOR, KisChannelInfo::FLOAT32, sizeof(float)));
+ m_channels.push_back(new KisChannelInfo(i18n("Short"), i18n("S"), PIXEL_SHORTWAVE * sizeof(float), KisChannelInfo::COLOR, KisChannelInfo::FLOAT32, sizeof(float)));
+ m_channels.push_back(new KisChannelInfo(i18n("Alpha"), i18n("A"), PIXEL_ALPHA * sizeof(float), KisChannelInfo::ALPHA, KisChannelInfo::FLOAT32, sizeof(float)));
+
+ m_alphaPos = PIXEL_ALPHA * sizeof(float);
+}
+
+KisLmsF32ColorSpace::~KisLmsF32ColorSpace()
+{
+}
+
+void KisLmsF32ColorSpace::setPixel(Q_UINT8 *dst, float longWave, float middleWave, float shortWave, float alpha) const
+{
+ Pixel *dstPixel = reinterpret_cast<Pixel *>(dst);
+
+ dstPixel->longWave = longWave;
+ dstPixel->middleWave = middleWave;
+ dstPixel->shortWave = shortWave;
+ dstPixel->alpha = alpha;
+}
+
+void KisLmsF32ColorSpace::getPixel(const Q_UINT8 *src, float *longWave, float *middleWave, float *shortWave, float *alpha) const
+{
+ const Pixel *srcPixel = reinterpret_cast<const Pixel *>(src);
+
+ *longWave = srcPixel->longWave;
+ *middleWave = srcPixel->middleWave;
+ *shortWave = srcPixel->shortWave;
+ *alpha = srcPixel->alpha;
+}
+
+void KisLmsF32ColorSpace::fromQColor(const QColor& c, Q_UINT8 *dstU8, KisProfile * /*profile*/)
+{
+ Pixel *dst = reinterpret_cast<Pixel *>(dstU8);
+
+ dst->longWave = computeLong(c.red(),c.green(),c.blue());
+ dst->middleWave = computeMiddle(c.red(),c.green(),c.blue());
+ dst->shortWave = computeShort(c.red(),c.green(),c.blue());
+}
+
+void KisLmsF32ColorSpace::fromQColor(const QColor& c, Q_UINT8 opacity, Q_UINT8 *dstU8, KisProfile * /*profile*/)
+{
+ Pixel *dst = reinterpret_cast<Pixel *>(dstU8);
+
+ dst->longWave = computeLong(c.red(),c.green(),c.blue());
+ dst->middleWave = computeMiddle(c.red(),c.green(),c.blue());
+ dst->shortWave = computeShort(c.red(),c.green(),c.blue());
+ dst->alpha = UINT8_TO_FLOAT(opacity);
+}
+
+void KisLmsF32ColorSpace::toQColor(const Q_UINT8 *srcU8, QColor *c, KisProfile * /*profile*/)
+{
+ const Pixel *src = reinterpret_cast<const Pixel *>(srcU8);
+
+ c->setRgb(computeRed(src->longWave,src->middleWave,src->shortWave), computeGreen(src->longWave,src->middleWave,src->shortWave), computeBlue(src->longWave,src->middleWave,src->shortWave));
+}
+
+void KisLmsF32ColorSpace::toQColor(const Q_UINT8 *srcU8, QColor *c, Q_UINT8 *opacity, KisProfile * /*profile*/)
+{
+ const Pixel *src = reinterpret_cast<const Pixel *>(srcU8);
+
+ c->setRgb(computeRed(src->longWave,src->middleWave,src->shortWave), computeGreen(src->longWave,src->middleWave,src->shortWave), computeBlue(src->longWave,src->middleWave,src->shortWave));
+ *opacity = FLOAT_TO_UINT8(src->alpha);
+}
+
+Q_UINT8 KisLmsF32ColorSpace::difference(const Q_UINT8 *src1U8, const Q_UINT8 *src2U8)
+{
+ const Pixel *src1 = reinterpret_cast<const Pixel *>(src1U8);
+ const Pixel *src2 = reinterpret_cast<const Pixel *>(src2U8);
+
+ return FLOAT_TO_UINT8(QMAX(QABS(src2->longWave - src1->longWave),
+ QMAX(QABS(src2->middleWave - src1->middleWave),
+ QABS(src2->shortWave - src1->shortWave))));
+}
+
+void KisLmsF32ColorSpace::mixColors(const Q_UINT8 **colors, const Q_UINT8 *weights, Q_UINT32 nColors, Q_UINT8 *dst) const
+{
+ float totalLong = 0, totalMiddle = 0, totalShort = 0, newAlpha = 0;
+
+ while (nColors--)
+ {
+ const Pixel *pixel = reinterpret_cast<const Pixel *>(*colors);
+
+ float alpha = pixel->alpha;
+ float alphaTimesWeight = alpha * UINT8_TO_FLOAT(*weights);
+
+ totalLong += pixel->longWave * alphaTimesWeight;
+ totalMiddle += pixel->middleWave * alphaTimesWeight;
+ totalShort += pixel->shortWave * alphaTimesWeight;
+ newAlpha += alphaTimesWeight;
+
+ weights++;
+ colors++;
+ }
+
+ Q_ASSERT(newAlpha <= F32_OPACITY_OPAQUE);
+
+ Pixel *dstPixel = reinterpret_cast<Pixel *>(dst);
+
+ dstPixel->alpha = newAlpha;
+
+ if (newAlpha > EPSILON) {
+ totalLong = totalLong / newAlpha;
+ totalMiddle = totalMiddle / newAlpha;
+ totalShort = totalShort / newAlpha;
+ }
+
+ dstPixel->longWave = totalLong;
+ dstPixel->middleWave = totalMiddle;
+ dstPixel->shortWave = totalShort;
+}
+
+QValueVector<KisChannelInfo *> KisLmsF32ColorSpace::channels() const
+{
+ return m_channels;
+}
+
+Q_UINT32 KisLmsF32ColorSpace::nChannels() const
+{
+ return MAX_CHANNEL_LMSA;
+}
+
+Q_UINT32 KisLmsF32ColorSpace::nColorChannels() const
+{
+ return MAX_CHANNEL_LMS;
+}
+
+Q_UINT32 KisLmsF32ColorSpace::pixelSize() const
+{
+ return MAX_CHANNEL_LMSA * sizeof(float);
+}
+
+QImage KisLmsF32ColorSpace::convertToQImage(const Q_UINT8 *dataU8, Q_INT32 width, Q_INT32 height,
+ KisProfile * /*dstProfile*/,
+ Q_INT32 /*renderingIntent*/, float /*exposure*/)
+
+{
+ const float *data = reinterpret_cast<const float *>(dataU8);
+
+ QImage img = QImage(width, height, 32, 0, QImage::LittleEndian);
+ img.setAlphaBuffer(true);
+
+ Q_INT32 i = 0;
+ uchar *j = img.bits();
+
+ while ( i < width * height * MAX_CHANNEL_LMSA) {
+ double l = *( data + i + PIXEL_LONGWAVE );
+ double m = *( data + i + PIXEL_MIDDLEWAVE );
+ double s = *( data + i + PIXEL_SHORTWAVE );
+ *( j + 3) = FLOAT_TO_UINT8(*( data + i + PIXEL_ALPHA ));
+ *( j + 2 ) = computeRed(l,m,s);
+ *( j + 1 ) = computeGreen(l,m,s);
+ *( j + 0 ) = computeBlue(l,m,s);
+ i += MAX_CHANNEL_LMSA;
+ j += MAX_CHANNEL_LMSA;
+ }
+
+ /*
+ if (srcProfile != 0 && dstProfile != 0) {
+ convertPixelsTo(img.bits(), srcProfile,
+ img.bits(), this, dstProfile,
+ width * height, renderingIntent);
+ }
+ */
+ return img;
+}
+
+
+void KisLmsF32ColorSpace::compositeOver(Q_UINT8 *dstRowStart, Q_INT32 dstRowStride, const Q_UINT8 *srcRowStart, Q_INT32 srcRowStride, const Q_UINT8 *maskRowStart, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 numColumns, float opacity)
+{
+ while (rows > 0) {
+
+ const float *src = reinterpret_cast<const float *>(srcRowStart);
+ float *dst = reinterpret_cast<float *>(dstRowStart);
+ const Q_UINT8 *mask = maskRowStart;
+ Q_INT32 columns = numColumns;
+
+ while (columns > 0) {
+
+ float srcAlpha = src[PIXEL_ALPHA];
+
+ // apply the alphamask
+ if (mask != 0) {
+ Q_UINT8 U8_mask = *mask;
+
+ if (U8_mask != OPACITY_OPAQUE) {
+ srcAlpha *= UINT8_TO_FLOAT(U8_mask);
+ }
+ mask++;
+ }
+
+ if (srcAlpha > F32_OPACITY_TRANSPARENT + EPSILON) {
+
+ if (opacity < F32_OPACITY_OPAQUE - EPSILON) {
+ srcAlpha *= opacity;
+ }
+
+ if (srcAlpha > F32_OPACITY_OPAQUE - EPSILON) {
+ memcpy(dst, src, MAX_CHANNEL_LMSA * sizeof(float));
+ } else {
+ float dstAlpha = dst[PIXEL_ALPHA];
+
+ float srcBlend;
+
+ if (dstAlpha > F32_OPACITY_OPAQUE - EPSILON) {
+ srcBlend = srcAlpha;
+ } else {
+ float newAlpha = dstAlpha + (F32_OPACITY_OPAQUE - dstAlpha) * srcAlpha;
+ dst[PIXEL_ALPHA] = newAlpha;
+
+ if (newAlpha > EPSILON) {
+ srcBlend = srcAlpha / newAlpha;
+ } else {
+ srcBlend = srcAlpha;
+ }
+ }
+
+ if (srcBlend > F32_OPACITY_OPAQUE - EPSILON) {
+ memcpy(dst, src, MAX_CHANNEL_LMS * sizeof(float));
+ } else {
+ dst[PIXEL_LONGWAVE] = FLOAT_BLEND(src[PIXEL_LONGWAVE], dst[PIXEL_LONGWAVE], srcBlend);
+ dst[PIXEL_MIDDLEWAVE] = FLOAT_BLEND(src[PIXEL_MIDDLEWAVE], dst[PIXEL_MIDDLEWAVE], srcBlend);
+ dst[PIXEL_SHORTWAVE] = FLOAT_BLEND(src[PIXEL_SHORTWAVE], dst[PIXEL_SHORTWAVE], srcBlend);
+ }
+ }
+ }
+
+ columns--;
+ src += MAX_CHANNEL_LMSA;
+ dst += MAX_CHANNEL_LMSA;
+ }
+
+ rows--;
+ srcRowStart += srcRowStride;
+ dstRowStart += dstRowStride;
+ if(maskRowStart) {
+ maskRowStart += maskRowStride;
+ }
+ }
+}
+
+void KisLmsF32ColorSpace::compositeErase(Q_UINT8 *dst,
+ Q_INT32 dstRowSize,
+ const Q_UINT8 *src,
+ Q_INT32 srcRowSize,
+ const Q_UINT8 *srcAlphaMask,
+ Q_INT32 maskRowStride,
+ Q_INT32 rows,
+ Q_INT32 cols,
+ float /*opacity*/)
+{
+ while (rows-- > 0)
+ {
+ const Pixel *s = reinterpret_cast<const Pixel *>(src);
+ Pixel *d = reinterpret_cast<Pixel *>(dst);
+ const Q_UINT8 *mask = srcAlphaMask;
+
+ for (Q_INT32 i = cols; i > 0; i--, s++, d++)
+ {
+ float srcAlpha = s->alpha;
+
+ // apply the alphamask
+ if (mask != 0) {
+ Q_UINT8 U8_mask = *mask;
+
+ if (U8_mask != OPACITY_OPAQUE) {
+ srcAlpha = FLOAT_BLEND(srcAlpha, F32_OPACITY_OPAQUE, UINT8_TO_FLOAT(U8_mask));
+ }
+ mask++;
+ }
+ d->alpha = srcAlpha * d->alpha;
+ }
+
+ dst += dstRowSize;
+ src += srcRowSize;
+ if(srcAlphaMask) {
+ srcAlphaMask += maskRowStride;
+ }
+ }
+}
+
+void KisLmsF32ColorSpace::compositeCopy(Q_UINT8 *dstRowStart, Q_INT32 dstRowStride, const Q_UINT8 *srcRowStart, Q_INT32 srcRowStride,
+ const Q_UINT8 */*maskRowStart*/, Q_INT32 /*maskRowStride*/, Q_INT32 rows, Q_INT32 numColumns, float /*opacity*/)
+{
+ while (rows > 0) {
+ memcpy(dstRowStart, srcRowStart, numColumns * sizeof(Pixel));
+ --rows;
+ srcRowStart += srcRowStride;
+ dstRowStart += dstRowStride;
+ }
+}
+
+void KisLmsF32ColorSpace::bitBlt(Q_UINT8 *dst,
+ Q_INT32 dstRowStride,
+ const Q_UINT8 *src,
+ Q_INT32 srcRowStride,
+ const Q_UINT8 *mask,
+ Q_INT32 maskRowStride,
+ Q_UINT8 U8_opacity,
+ Q_INT32 rows,
+ Q_INT32 cols,
+ const KisCompositeOp& op)
+{
+ float opacity = UINT8_TO_FLOAT(U8_opacity);
+
+ switch (op.op()) {
+ case COMPOSITE_UNDEF:
+ // Undefined == no composition
+ break;
+ case COMPOSITE_OVER:
+ compositeOver(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_COPY:
+ compositeCopy(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_ERASE:
+ compositeErase(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
+ break;
+ default:
+ break;
+ }
+}
+
+KisCompositeOpList KisLmsF32ColorSpace::userVisiblecompositeOps() const
+{
+ KisCompositeOpList list;
+
+ list.append(KisCompositeOp(COMPOSITE_OVER));
+ return list;
+}
+
diff --git a/krita/colorspaces/lms_f32/kis_lms_f32_colorspace.h b/krita/colorspaces/lms_f32/kis_lms_f32_colorspace.h
new file mode 100644
index 00000000..8d5d27d9
--- /dev/null
+++ b/krita/colorspaces/lms_f32/kis_lms_f32_colorspace.h
@@ -0,0 +1,157 @@
+/*
+ * 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"
+
+class KisColorSpaceFactoryRegistry;
+
+class KRITATOOL_EXPORT KisLmsF32ColorSpace : public KisF32BaseColorSpace {
+public:
+ KisLmsF32ColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p);
+ virtual ~KisLmsF32ColorSpace();
+
+ virtual bool willDegrade(ColorSpaceIndependence independence)
+ {
+ if (independence == TO_RGBA8 || independence == TO_LAB16)
+ return true;
+ else
+ return false;
+ };
+
+
+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, KisProfile * profile = 0);
+ virtual void fromQColor(const QColor& c, Q_UINT8 opacity, Q_UINT8 *dst, KisProfile * profile = 0);
+
+ virtual void toQColor(const Q_UINT8 *src, QColor *c, KisProfile * profile = 0);
+ virtual void toQColor(const Q_UINT8 *src, QColor *c, Q_UINT8 *opacity, KisProfile * profile = 0);
+
+ virtual Q_UINT8 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 Q_UINT32 nChannels() const;
+ virtual Q_UINT32 nColorChannels() const;
+ virtual Q_UINT32 pixelSize() const;
+
+ virtual bool hasHighDynamicRange() const { return false; }
+
+ 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 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_
+
diff --git a/krita/colorspaces/lms_f32/krita_lms_f32_plugin.desktop b/krita/colorspaces/lms_f32/krita_lms_f32_plugin.desktop
new file mode 100644
index 00000000..89951209
--- /dev/null
+++ b/krita/colorspaces/lms_f32/krita_lms_f32_plugin.desktop
@@ -0,0 +1,77 @@
+[Desktop Entry]
+Name=LMS Color Model (32-bit float)
+Name[bg]=Цветови модел LMS (32 бита)
+Name[ca]=Model de color LMS (paleta de 32 bits)
+Name[cy]=Model Lliw LMS (arnawf 32-did)
+Name[da]=LMS-farvemodel (32-bit float)
+Name[de]=LMS-Farbmodell (32-bit Fließkomma)
+Name[el]=Χρωματικό μοντέλο LMS (32 bit δεκαδικοί)
+Name[en_GB]=LMS Colour Model (32-bit float)
+Name[eo]=LMS-kolormodelo (32-bita flupunkto)
+Name[es]=Modelo de color LMS (decimal de 32 bits)
+Name[et]=LMS värvimudel (32-bitine murdarv)
+Name[fa]=مدل رنگ LMS )شناور ۳۲ بیتی(
+Name[fr]=Modèle de couleurs LMS (flottants 32 bits)
+Name[fy]=LMS-kleurmodel (32-bit float)
+Name[gl]=Modelo de Cores LMS (vírgula flutuante 32-bit)
+Name[he]=מודל צבעים LMS (32 סיביות)
+Name[hu]=LMS színmodell (32 bites lebegőpontos)
+Name[is]=LMS litategund (32-bita fleytitala)
+Name[it]=Modello di colore LMS (virgola mobile a 32 bit)
+Name[ja]=LMS カラーモデル (32 ビット浮動小数)
+Name[km]=គំរូ​ពណ៌ LMS (ចំនួន​ទស្សភាគ ៣២ ប៊ីត)
+Name[nb]=LMS-fargemodell (32-bit flyttall)
+Name[nds]=LMS-Klöörmodell (32-Bit Fleetkomma)
+Name[ne]=LMS रङ मोडेल (३२-बिट उत्प्लावन)
+Name[nl]=LMS-kleurmodel (32-bit float)
+Name[pl]=Przestrzeń barw LMS (32-bitowa liczba zmiennoprzecinkowa)
+Name[pt]=Modelo de Cor LMS (v. flutuante de 32-bits)
+Name[pt_BR]=Modelo de Cor LMS (ponto flutuante de 32-bits)
+Name[ru]=LMS (32-бит с плавающей точкой)
+Name[sk]=Model farieb LMS (32-bitové reálne čísla)
+Name[sl]=Barvni model LMS (32-bitna decimalno število)
+Name[sr]=LMS модел боја (32-битно реално)
+Name[sr@Latn]=LMS model boja (32-bitno realno)
+Name[sv]=LMS-färgmodell (32-bitars flyttal)
+Name[uk]=Модель кольору LMS (32-бітне дробове число)
+Name[uz]=LMS rang usuli (32-bit kasr)
+Name[uz@cyrillic]=LMS ранг усули (32-бит каср)
+Name[zh_CN]=LMS 色彩模型(32 位浮点)
+Name[zh_TW]=LMS 色彩模型 (32-bit 浮點數)
+Comment=Color model for LMS cone space (Long Middle and Short wavelengths)
+Comment[bg]=Цветови модел за интервали LMS (дълги, средни и къси вълни)
+Comment[ca]=Model de color per a conus d'espai LMC (amples d'ona llargs, mitjos i curts)
+Comment[cy]=Model lliw ar gyfer gofod côn LMS (tonfeddi Hir, Canolig a Byr)
+Comment[da]=Farvemodel for LMS-keglerum (Lange, mellemliggende og korte bølgelængder)
+Comment[de]=Farbmodell für LMS cone space (Lange, Mittelere und Kurze Wellenlängen)
+Comment[el]=Χρωματικό μοντέλο για χώρο χρωμάτων LMS (Μακρά μεσαία και σύντομα μήκη κύματος)
+Comment[en_GB]=Colour model for LMS cone space (Long Middle and Short wavelengths)
+Comment[es]=Modelo de color para el espacio cónico LMS (con longitudes de onda larga, media y corta)
+Comment[et]=LMS koonuse (pikad, keskmised ja lühikesed lainepikkused) värvimudel
+Comment[fa]=مدل رنگ برای فضای مخروط LMS )طول موج بلند، متوسط و کوتاه(
+Comment[fr]=Modèle de couleurs pour l'espace conique LMS (longueurs d'ondes longues, moyennes et courtes)
+Comment[fy]=Kleurmodel Foar LMS-kegelromte (lange, middelt en koarte golflingten)
+Comment[gl]=Modelo de Cores para o espazo do cone LMS (Long Middle and Short wavelengths)
+Comment[hu]=Színmodell az LMS kúptérhez (hosszú, közepes és rövid hullámhosszak)
+Comment[is]=Litategund fyrir LMS keilubil (löng miðlungs og stutt bylgjulengd)
+Comment[it]=Modello di colore per lo spazio conico LMS (lunghezze d'onda lunghe, medie e corte)
+Comment[km]=មូដែល​ពណ៌​សម្រាប់ LMS ដែល​មាន​ចន្លោះ​រាង​សាជី​មូល​ (ប្រវែង​រលក​ខ្លី និង​ពាក់​កណ្ដាល​វែង)
+Comment[nb]=Fargemodell for LMS-kjeglerom (Long Middle og Short bølgelengder)
+Comment[nds]=Klöörmodell för LMS-Kegelruum (Lang, middel un kort Bülgenlängden)
+Comment[ne]=LMS शंकु खाली स्थान (लामो मध्य र छोटो तरङलम्बाइहरू) का लागि रङ मोडेल
+Comment[nl]=Kleurmodel voor LMS-kegelruimte (lange, middel en korte golflengten)
+Comment[pl]=Przestrzeń barw dla przestrzeni stożkowej LMS (średnie długie i krótkie długości fal)
+Comment[pt]=Modelo de cor para o espaço cónico do LMS (comprimentos de onda longos, médios e curtos)
+Comment[pt_BR]=Modelo de cor para o espaço cônico do LMS (comprimentos de onda longos, médios e curtos)
+Comment[ru]=Цветовое пространство LMS (Long Middle and Short wavelengths)
+Comment[sk]=Model farieb pre LMS kónický priestor (dlhé, stredné a krátke vlnové dĺžky)
+Comment[sl]=Barvni model za prostor stožca LMS (dolge, srednje in kratke valovne dolžine)
+Comment[sr]=Модел боја за LMS конусни простор (дуге средње и кратке таласне дужине)
+Comment[sr@Latn]=Model boja za LMS konusni prostor (duge srednje i kratke talasne dužine)
+Comment[sv]=Färgmodell för LMS-konrymd (Långa, mellanliggande och korta våglängder)
+Comment[uk]=Модель кольорів для конусного простору LMS (довгі середні і короткі довжини кольорів)
+Comment[zh_TW]=LMS cone space 顏色模式(Long Middle and Short 波長)
+ServiceTypes=Krita/ColorSpace
+Type=Service
+X-KDE-Library=krita_lms_f32_plugin
+X-Krita-Version=2
diff --git a/krita/colorspaces/lms_f32/lms_f32_plugin.cc b/krita/colorspaces/lms_f32/lms_f32_plugin.cc
new file mode 100644
index 00000000..67df5e4f
--- /dev/null
+++ b/krita/colorspaces/lms_f32/lms_f32_plugin.cc
@@ -0,0 +1,64 @@
+/*
+* 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_debug_areas.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());
+
+ 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")), colorSpaceLMSF32) );
+ }
+
+}
+
+LMSF32Plugin::~LMSF32Plugin()
+{
+}
+
+#include "lms_f32_plugin.moc"
diff --git a/krita/colorspaces/lms_f32/lms_f32_plugin.h b/krita/colorspaces/lms_f32/lms_f32_plugin.h
new file mode 100644
index 00000000..b8d02b18
--- /dev/null
+++ b/krita/colorspaces/lms_f32/lms_f32_plugin.h
@@ -0,0 +1,39 @@
+/*
+ * 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_
diff --git a/krita/colorspaces/lms_f32/lms_f32_plugin.rc b/krita/colorspaces/lms_f32/lms_f32_plugin.rc
new file mode 100644
index 00000000..ac6ec45f
--- /dev/null
+++ b/krita/colorspaces/lms_f32/lms_f32_plugin.rc
@@ -0,0 +1,9 @@
+<!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>