summaryrefslogtreecommitdiffstats
path: root/krita/colorspaces/rgb_u16
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/rgb_u16
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/rgb_u16')
-rw-r--r--krita/colorspaces/rgb_u16/Makefile.am32
-rw-r--r--krita/colorspaces/rgb_u16/kis_rgb_u16_colorspace.cc869
-rw-r--r--krita/colorspaces/rgb_u16/kis_rgb_u16_colorspace.h128
-rw-r--r--krita/colorspaces/rgb_u16/krita_rgb_u16_plugin.desktop80
-rw-r--r--krita/colorspaces/rgb_u16/rgb_u16_plugin.cc61
-rw-r--r--krita/colorspaces/rgb_u16/rgb_u16_plugin.h36
-rw-r--r--krita/colorspaces/rgb_u16/tests/Makefile.am17
-rw-r--r--krita/colorspaces/rgb_u16/tests/kis_strategy_colorspace_rgb_u16_tester.cc524
-rw-r--r--krita/colorspaces/rgb_u16/tests/kis_strategy_colorspace_rgb_u16_tester.h46
9 files changed, 1793 insertions, 0 deletions
diff --git a/krita/colorspaces/rgb_u16/Makefile.am b/krita/colorspaces/rgb_u16/Makefile.am
new file mode 100644
index 00000000..927debfa
--- /dev/null
+++ b/krita/colorspaces/rgb_u16/Makefile.am
@@ -0,0 +1,32 @@
+# location for the rc file
+kde_services_DATA = krita_rgb_u16_plugin.desktop
+
+INCLUDES = -I$(srcdir)/../../sdk \
+ -I$(srcdir)/../../kritacolor/color_strategy/ \
+ -I$(srcdir)/../../kritacolor \
+ $(KOFFICE_INCLUDES) \
+ $(all_includes)
+
+lib_LTLIBRARIES = libkrita_rgb_u16.la
+libkrita_rgb_u16_la_SOURCES = kis_rgb_u16_colorspace.cc
+libkrita_rgb_u16_la_LDFLAGS = $(all_libraries)
+libkrita_rgb_u16_la_LIBADD = ../../kritacolor/libkritacolor.la
+
+# Install this plugin in the KDE modules directory
+kde_module_LTLIBRARIES = krita_rgb_u16_plugin.la
+
+# Srcs for the plugin
+krita_rgb_u16_plugin_la_SOURCES = rgb_u16_plugin.cc
+noinst_HEADERS = rgb_u16_plugin.h kis_rgb_u16_colorspace.h
+
+krita_rgb_u16_plugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+krita_rgb_u16_plugin_la_LIBADD = libkrita_rgb_u16.la ../../kritacolor/libkritacolor.la
+
+krita_rgb_u16_plugin_la_METASOURCES = AUTO
+
+if include_kunittest_tests
+TESTSDIR = tests
+endif
+
+SUBDIRS = . $(TESTSDIR)
+
diff --git a/krita/colorspaces/rgb_u16/kis_rgb_u16_colorspace.cc b/krita/colorspaces/rgb_u16/kis_rgb_u16_colorspace.cc
new file mode 100644
index 00000000..7ec94671
--- /dev/null
+++ b/krita/colorspaces/rgb_u16/kis_rgb_u16_colorspace.cc
@@ -0,0 +1,869 @@
+/*
+ * 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>
+ *
+ * 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 <qcolor.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <kglobal.h>
+
+#include "kis_rgb_u16_colorspace.h"
+#include "kis_u16_base_colorspace.h"
+#include "kis_color_conversions.h"
+#include "kis_integer_maths.h"
+
+namespace {
+ const Q_INT32 MAX_CHANNEL_RGB = 3;
+ const Q_INT32 MAX_CHANNEL_RGBA = 4;
+}
+
+// XXX: already defined is superclass?
+//const Q_UINT16 KisRgbU16ColorSpace::U16_OPACITY_OPAQUE;
+//const Q_UINT16 KisRgbU16ColorSpace::U16_OPACITY_TRANSPARENT;
+
+KisRgbU16ColorSpace::KisRgbU16ColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p) :
+ KisU16BaseColorSpace(KisID("RGBA16", i18n("RGB (16-bit integer/channel)")), TYPE_BGRA_16, icSigRgbData, parent, p)
+{
+ m_channels.push_back(new KisChannelInfo(i18n("Red"), i18n("R"), PIXEL_RED * sizeof(Q_UINT16), KisChannelInfo::COLOR, KisChannelInfo::UINT16, sizeof(Q_UINT16), QColor(255,0,0)));
+ m_channels.push_back(new KisChannelInfo(i18n("Green"), i18n("G"), PIXEL_GREEN * sizeof(Q_UINT16), KisChannelInfo::COLOR, KisChannelInfo::UINT16, sizeof(Q_UINT16), QColor(0,255,0)));
+ m_channels.push_back(new KisChannelInfo(i18n("Blue"), i18n("B"), PIXEL_BLUE * sizeof(Q_UINT16), KisChannelInfo::COLOR, KisChannelInfo::UINT16, sizeof(Q_UINT16), QColor(0,0,255)));
+ m_channels.push_back(new KisChannelInfo(i18n("Alpha"), i18n("A"), PIXEL_ALPHA * sizeof(Q_UINT16), KisChannelInfo::ALPHA, KisChannelInfo::UINT16, sizeof(Q_UINT16)));
+
+ m_alphaPos = PIXEL_ALPHA * sizeof(Q_UINT16);
+
+ init();
+}
+
+KisRgbU16ColorSpace::~KisRgbU16ColorSpace()
+{
+}
+
+void KisRgbU16ColorSpace::setPixel(Q_UINT8 *dst, Q_UINT16 red, Q_UINT16 green, Q_UINT16 blue, Q_UINT16 alpha) const
+{
+ Pixel *dstPixel = reinterpret_cast<Pixel *>(dst);
+
+ dstPixel->red = red;
+ dstPixel->green = green;
+ dstPixel->blue = blue;
+ dstPixel->alpha = alpha;
+}
+
+void KisRgbU16ColorSpace::getPixel(const Q_UINT8 *src, Q_UINT16 *red, Q_UINT16 *green, Q_UINT16 *blue, Q_UINT16 *alpha) const
+{
+ const Pixel *srcPixel = reinterpret_cast<const Pixel *>(src);
+
+ *red = srcPixel->red;
+ *green = srcPixel->green;
+ *blue = srcPixel->blue;
+ *alpha = srcPixel->alpha;
+}
+
+void KisRgbU16ColorSpace::mixColors(const Q_UINT8 **colors, const Q_UINT8 *weights, Q_UINT32 nColors, Q_UINT8 *dst) const
+{
+ Q_UINT32 totalRed = 0, totalGreen = 0, totalBlue = 0, newAlpha = 0;
+
+ while (nColors--)
+ {
+ const Pixel *pixel = reinterpret_cast<const Pixel *>(*colors);
+
+ Q_UINT32 alpha = pixel->alpha;
+ Q_UINT32 alphaTimesWeight = UINT16_MULT(alpha, UINT8_TO_UINT16(*weights));
+
+ totalRed += UINT16_MULT(pixel->red, alphaTimesWeight);
+ totalGreen += UINT16_MULT(pixel->green, alphaTimesWeight);
+ totalBlue += UINT16_MULT(pixel->blue, alphaTimesWeight);
+ newAlpha += alphaTimesWeight;
+
+ weights++;
+ colors++;
+ }
+
+ Q_ASSERT(newAlpha <= U16_OPACITY_OPAQUE);
+
+ Pixel *dstPixel = reinterpret_cast<Pixel *>(dst);
+
+ dstPixel->alpha = newAlpha;
+
+ if (newAlpha > 0) {
+ totalRed = UINT16_DIVIDE(totalRed, newAlpha);
+ totalGreen = UINT16_DIVIDE(totalGreen, newAlpha);
+ totalBlue = UINT16_DIVIDE(totalBlue, newAlpha);
+ }
+
+ dstPixel->red = totalRed;
+ dstPixel->green = totalGreen;
+ dstPixel->blue = totalBlue;
+}
+
+
+void KisRgbU16ColorSpace::convolveColors(Q_UINT8** colors, Q_INT32* kernelValues, KisChannelInfo::enumChannelFlags channelFlags, Q_UINT8 *dst,
+ Q_INT32 factor, Q_INT32 offset, Q_INT32 nColors) const
+{
+ Q_INT32 totalRed = 0, totalGreen = 0, totalBlue = 0, totalAlpha = 0;
+
+ while (nColors--)
+ {
+ const Pixel * pixel = reinterpret_cast<const Pixel *>( *colors );
+
+ Q_INT32 weight = *kernelValues;
+
+ if (weight != 0) {
+ totalRed += pixel->red * weight;
+ totalGreen += pixel->green * weight;
+ totalBlue += pixel->blue * weight;
+ totalAlpha +=pixel->alpha * weight;
+ }
+ colors++;
+ kernelValues++;
+ }
+
+ Pixel * p = reinterpret_cast< Pixel *>( dst );
+
+ if (channelFlags & KisChannelInfo::FLAG_COLOR) {
+ p->red = CLAMP( ( totalRed / factor) + offset, 0, Q_UINT16_MAX);
+ p->green = CLAMP( ( totalGreen / factor) + offset, 0, Q_UINT16_MAX);
+ p->blue = CLAMP( ( totalBlue / factor) + offset, 0, Q_UINT16_MAX);
+ }
+ if (channelFlags & KisChannelInfo::FLAG_ALPHA) {
+ p->alpha = CLAMP((totalAlpha/ factor) + offset, 0, Q_UINT16_MAX);
+ }
+}
+
+
+void KisRgbU16ColorSpace::invertColor(Q_UINT8 * src, Q_INT32 nPixels)
+{
+ Q_UINT32 psize = pixelSize();
+
+ while (nPixels--)
+ {
+ Pixel * p = reinterpret_cast< Pixel *>( src );
+ p->red = Q_UINT16_MAX - p->red;
+ p->green = Q_UINT16_MAX - p->green;
+ p->blue = Q_UINT16_MAX - p->blue;
+ src += psize;
+ }
+}
+
+Q_UINT8 KisRgbU16ColorSpace::intensity8(const Q_UINT8 * src) const
+{
+ const Pixel * p = reinterpret_cast<const Pixel *>( src );
+
+ return UINT16_TO_UINT8(static_cast<Q_UINT16>((p->red * 0.30 + p->green * 0.59 + p->blue * 0.11) + 0.5));
+}
+
+
+QValueVector<KisChannelInfo *> KisRgbU16ColorSpace::channels() const
+{
+ return m_channels;
+}
+
+Q_UINT32 KisRgbU16ColorSpace::nChannels() const
+{
+ return MAX_CHANNEL_RGBA;
+}
+
+Q_UINT32 KisRgbU16ColorSpace::nColorChannels() const
+{
+ return MAX_CHANNEL_RGB;
+}
+
+Q_UINT32 KisRgbU16ColorSpace::pixelSize() const
+{
+ return MAX_CHANNEL_RGBA * sizeof(Q_UINT16);
+}
+
+
+void KisRgbU16ColorSpace::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, Q_UINT16 opacity)
+{
+ while (rows > 0) {
+
+ const Q_UINT16 *src = reinterpret_cast<const Q_UINT16 *>(srcRowStart);
+ Q_UINT16 *dst = reinterpret_cast<Q_UINT16 *>(dstRowStart);
+ const Q_UINT8 *mask = maskRowStart;
+ Q_INT32 columns = numColumns;
+
+ while (columns > 0) {
+
+ Q_UINT16 srcAlpha = src[PIXEL_ALPHA];
+
+ // apply the alphamask
+ if (mask != 0) {
+ Q_UINT8 U8_mask = *mask;
+
+ if (U8_mask != OPACITY_OPAQUE) {
+ srcAlpha = UINT16_MULT(srcAlpha, UINT8_TO_UINT16(U8_mask));
+ }
+ mask++;
+ }
+
+ if (srcAlpha != U16_OPACITY_TRANSPARENT) {
+
+ if (opacity != U16_OPACITY_OPAQUE) {
+ srcAlpha = UINT16_MULT(srcAlpha, opacity);
+ }
+
+ if (srcAlpha == U16_OPACITY_OPAQUE) {
+ memcpy(dst, src, MAX_CHANNEL_RGBA * sizeof(Q_UINT16));
+ } else {
+ Q_UINT16 dstAlpha = dst[PIXEL_ALPHA];
+
+ Q_UINT16 srcBlend;
+
+ if (dstAlpha == U16_OPACITY_OPAQUE) {
+ srcBlend = srcAlpha;
+ } else {
+ Q_UINT16 newAlpha = dstAlpha + UINT16_MULT(U16_OPACITY_OPAQUE - dstAlpha, srcAlpha);
+ dst[PIXEL_ALPHA] = newAlpha;
+
+ if (newAlpha != 0) {
+ srcBlend = UINT16_DIVIDE(srcAlpha, newAlpha);
+ } else {
+ srcBlend = srcAlpha;
+ }
+ }
+
+ if (srcBlend == U16_OPACITY_OPAQUE) {
+ memcpy(dst, src, MAX_CHANNEL_RGB * sizeof(Q_UINT16));
+ } else {
+ dst[PIXEL_RED] = UINT16_BLEND(src[PIXEL_RED], dst[PIXEL_RED], srcBlend);
+ dst[PIXEL_GREEN] = UINT16_BLEND(src[PIXEL_GREEN], dst[PIXEL_GREEN], srcBlend);
+ dst[PIXEL_BLUE] = UINT16_BLEND(src[PIXEL_BLUE], dst[PIXEL_BLUE], srcBlend);
+ }
+ }
+ }
+
+ columns--;
+ src += MAX_CHANNEL_RGBA;
+ dst += MAX_CHANNEL_RGBA;
+ }
+
+ rows--;
+ srcRowStart += srcRowStride;
+ dstRowStart += dstRowStride;
+ if(maskRowStart) {
+ maskRowStart += maskRowStride;
+ }
+ }
+}
+
+#define COMMON_COMPOSITE_OP_PROLOG() \
+ while (rows > 0) { \
+ \
+ const Q_UINT16 *src = reinterpret_cast<const Q_UINT16 *>(srcRowStart); \
+ Q_UINT16 *dst = reinterpret_cast<Q_UINT16 *>(dstRowStart); \
+ Q_INT32 columns = numColumns; \
+ const Q_UINT8 *mask = maskRowStart; \
+ \
+ while (columns > 0) { \
+ \
+ Q_UINT16 srcAlpha = src[PIXEL_ALPHA]; \
+ Q_UINT16 dstAlpha = dst[PIXEL_ALPHA]; \
+ \
+ srcAlpha = QMIN(srcAlpha, dstAlpha); \
+ \
+ if (mask != 0) { \
+ Q_UINT8 U8_mask = *mask; \
+ \
+ if (U8_mask != OPACITY_OPAQUE) { \
+ srcAlpha = UINT16_MULT(srcAlpha, UINT8_TO_UINT16(U8_mask)); \
+ } \
+ mask++; \
+ } \
+ \
+ if (srcAlpha != U16_OPACITY_TRANSPARENT) { \
+ \
+ if (opacity != U16_OPACITY_OPAQUE) { \
+ srcAlpha = UINT16_MULT(srcAlpha, opacity); \
+ } \
+ \
+ Q_UINT16 srcBlend; \
+ \
+ if (dstAlpha == U16_OPACITY_OPAQUE) { \
+ srcBlend = srcAlpha; \
+ } else { \
+ Q_UINT16 newAlpha = dstAlpha + UINT16_MULT(U16_OPACITY_OPAQUE - dstAlpha, srcAlpha); \
+ dst[PIXEL_ALPHA] = newAlpha; \
+ \
+ if (newAlpha != 0) { \
+ srcBlend = UINT16_DIVIDE(srcAlpha, newAlpha); \
+ } else { \
+ srcBlend = srcAlpha; \
+ } \
+ }
+
+#define COMMON_COMPOSITE_OP_EPILOG() \
+ } \
+ \
+ columns--; \
+ src += MAX_CHANNEL_RGBA; \
+ dst += MAX_CHANNEL_RGBA; \
+ } \
+ \
+ rows--; \
+ srcRowStart += srcRowStride; \
+ dstRowStart += dstRowStride; \
+ if(maskRowStart) { \
+ maskRowStart += maskRowStride; \
+ } \
+ }
+
+void KisRgbU16ColorSpace::compositeMultiply(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, Q_UINT16 opacity)
+{
+ COMMON_COMPOSITE_OP_PROLOG();
+
+ {
+
+ for (int channel = 0; channel < MAX_CHANNEL_RGB; channel++) {
+ Q_UINT16 srcColor = src[channel];
+ Q_UINT16 dstColor = dst[channel];
+
+ srcColor = UINT16_MULT(srcColor, dstColor);
+
+ dst[channel] = UINT16_BLEND(srcColor, dstColor, srcBlend);
+
+ }
+ }
+
+ COMMON_COMPOSITE_OP_EPILOG();
+}
+
+void KisRgbU16ColorSpace::compositeDivide(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, Q_UINT16 opacity)
+{
+ COMMON_COMPOSITE_OP_PROLOG();
+
+ {
+ for (int channel = 0; channel < MAX_CHANNEL_RGB; channel++) {
+
+ Q_UINT16 srcColor = src[channel];
+ Q_UINT16 dstColor = dst[channel];
+
+ srcColor = QMIN((dstColor * (UINT16_MAX + 1u) + (srcColor / 2u)) / (1u + srcColor), UINT16_MAX);
+
+ Q_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend);
+
+ dst[channel] = newColor;
+ }
+ }
+
+ COMMON_COMPOSITE_OP_EPILOG();
+}
+
+void KisRgbU16ColorSpace::compositeScreen(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, Q_UINT16 opacity)
+{
+ COMMON_COMPOSITE_OP_PROLOG();
+
+ {
+ for (int channel = 0; channel < MAX_CHANNEL_RGB; channel++) {
+
+ Q_UINT16 srcColor = src[channel];
+ Q_UINT16 dstColor = dst[channel];
+
+ srcColor = UINT16_MAX - UINT16_MULT(UINT16_MAX - dstColor, UINT16_MAX - srcColor);
+
+ Q_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend);
+
+ dst[channel] = newColor;
+ }
+ }
+
+ COMMON_COMPOSITE_OP_EPILOG();
+}
+
+void KisRgbU16ColorSpace::compositeOverlay(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, Q_UINT16 opacity)
+{
+ COMMON_COMPOSITE_OP_PROLOG();
+
+ {
+ for (int channel = 0; channel < MAX_CHANNEL_RGB; channel++) {
+
+ Q_UINT16 srcColor = src[channel];
+ Q_UINT16 dstColor = dst[channel];
+
+ srcColor = UINT16_MULT(dstColor, dstColor + 2u * UINT16_MULT(srcColor, UINT16_MAX - dstColor));
+
+ Q_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend);
+
+ dst[channel] = newColor;
+ }
+ }
+
+ COMMON_COMPOSITE_OP_EPILOG();
+}
+
+void KisRgbU16ColorSpace::compositeDodge(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, Q_UINT16 opacity)
+{
+ COMMON_COMPOSITE_OP_PROLOG();
+
+ {
+ for (int channel = 0; channel < MAX_CHANNEL_RGB; channel++) {
+
+ Q_UINT16 srcColor = src[channel];
+ Q_UINT16 dstColor = dst[channel];
+
+ srcColor = QMIN((dstColor * (UINT16_MAX + 1u)) / (UINT16_MAX + 1u - srcColor), UINT16_MAX);
+
+ Q_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend);
+
+ dst[channel] = newColor;
+ }
+ }
+
+ COMMON_COMPOSITE_OP_EPILOG();
+}
+
+void KisRgbU16ColorSpace::compositeBurn(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, Q_UINT16 opacity)
+{
+ COMMON_COMPOSITE_OP_PROLOG();
+
+ {
+ for (int channel = 0; channel < MAX_CHANNEL_RGB; channel++) {
+
+ Q_UINT16 srcColor = src[channel];
+ Q_UINT16 dstColor = dst[channel];
+
+ srcColor = kMin(((UINT16_MAX - dstColor) * (UINT16_MAX + 1u)) / (srcColor + 1u), UINT16_MAX);
+ srcColor = kClamp(UINT16_MAX - srcColor, 0u, UINT16_MAX);
+
+ Q_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend);
+
+ dst[channel] = newColor;
+ }
+ }
+
+ COMMON_COMPOSITE_OP_EPILOG();
+}
+
+void KisRgbU16ColorSpace::compositeDarken(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, Q_UINT16 opacity)
+{
+ COMMON_COMPOSITE_OP_PROLOG();
+
+ {
+ for (int channel = 0; channel < MAX_CHANNEL_RGB; channel++) {
+
+ Q_UINT16 srcColor = src[channel];
+ Q_UINT16 dstColor = dst[channel];
+
+ srcColor = QMIN(srcColor, dstColor);
+
+ Q_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend);
+
+ dst[channel] = newColor;
+ }
+ }
+
+ COMMON_COMPOSITE_OP_EPILOG();
+}
+
+void KisRgbU16ColorSpace::compositeLighten(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, Q_UINT16 opacity)
+{
+ COMMON_COMPOSITE_OP_PROLOG();
+
+ {
+ for (int channel = 0; channel < MAX_CHANNEL_RGB; channel++) {
+
+ Q_UINT16 srcColor = src[channel];
+ Q_UINT16 dstColor = dst[channel];
+
+ srcColor = QMAX(srcColor, dstColor);
+
+ Q_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend);
+
+ dst[channel] = newColor;
+ }
+ }
+
+ COMMON_COMPOSITE_OP_EPILOG();
+}
+
+void KisRgbU16ColorSpace::compositeHue(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, Q_UINT16 opacity)
+{
+ COMMON_COMPOSITE_OP_PROLOG();
+
+ {
+ float FSrcRed = static_cast<float>(src[PIXEL_RED]) / UINT16_MAX;
+ float FSrcGreen = static_cast<float>(src[PIXEL_GREEN]) / UINT16_MAX;
+ float FSrcBlue = static_cast<float>(src[PIXEL_BLUE]) / UINT16_MAX;
+
+ Q_UINT16 dstRed = dst[PIXEL_RED];
+ Q_UINT16 dstGreen = dst[PIXEL_GREEN];
+ Q_UINT16 dstBlue = dst[PIXEL_BLUE];
+
+ float FDstRed = static_cast<float>(dstRed) / UINT16_MAX;
+ float FDstGreen = static_cast<float>(dstGreen) / UINT16_MAX;
+ float FDstBlue = static_cast<float>(dstBlue) / UINT16_MAX;
+
+ float srcHue;
+ float srcSaturation;
+ float srcValue;
+
+ float dstHue;
+ float dstSaturation;
+ float dstValue;
+
+ RGBToHSV(FSrcRed, FSrcGreen, FSrcBlue, &srcHue, &srcSaturation, &srcValue);
+ RGBToHSV(FDstRed, FDstGreen, FDstBlue, &dstHue, &dstSaturation, &dstValue);
+
+ HSVToRGB(srcHue, dstSaturation, dstValue, &FSrcRed, &FSrcGreen, &FSrcBlue);
+
+ Q_UINT16 srcRed = static_cast<Q_UINT16>(FSrcRed * UINT16_MAX + 0.5);
+ Q_UINT16 srcGreen = static_cast<Q_UINT16>(FSrcGreen * UINT16_MAX + 0.5);
+ Q_UINT16 srcBlue = static_cast<Q_UINT16>(FSrcBlue * UINT16_MAX + 0.5);
+
+ dst[PIXEL_RED] = UINT16_BLEND(srcRed, dstRed, srcBlend);
+ dst[PIXEL_GREEN] = UINT16_BLEND(srcGreen, dstGreen, srcBlend);
+ dst[PIXEL_BLUE] = UINT16_BLEND(srcBlue, dstBlue, srcBlend);
+ }
+
+ COMMON_COMPOSITE_OP_EPILOG();
+}
+
+void KisRgbU16ColorSpace::compositeSaturation(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, Q_UINT16 opacity)
+{
+ COMMON_COMPOSITE_OP_PROLOG();
+
+ {
+ float FSrcRed = static_cast<float>(src[PIXEL_RED]) / UINT16_MAX;
+ float FSrcGreen = static_cast<float>(src[PIXEL_GREEN]) / UINT16_MAX;
+ float FSrcBlue = static_cast<float>(src[PIXEL_BLUE]) / UINT16_MAX;
+
+ Q_UINT16 dstRed = dst[PIXEL_RED];
+ Q_UINT16 dstGreen = dst[PIXEL_GREEN];
+ Q_UINT16 dstBlue = dst[PIXEL_BLUE];
+
+ float FDstRed = static_cast<float>(dstRed) / UINT16_MAX;
+ float FDstGreen = static_cast<float>(dstGreen) / UINT16_MAX;
+ float FDstBlue = static_cast<float>(dstBlue) / UINT16_MAX;
+
+ float srcHue;
+ float srcSaturation;
+ float srcValue;
+
+ float dstHue;
+ float dstSaturation;
+ float dstValue;
+
+ RGBToHSV(FSrcRed, FSrcGreen, FSrcBlue, &srcHue, &srcSaturation, &srcValue);
+ RGBToHSV(FDstRed, FDstGreen, FDstBlue, &dstHue, &dstSaturation, &dstValue);
+
+ HSVToRGB(dstHue, srcSaturation, dstValue, &FSrcRed, &FSrcGreen, &FSrcBlue);
+
+ Q_UINT16 srcRed = static_cast<Q_UINT16>(FSrcRed * UINT16_MAX + 0.5);
+ Q_UINT16 srcGreen = static_cast<Q_UINT16>(FSrcGreen * UINT16_MAX + 0.5);
+ Q_UINT16 srcBlue = static_cast<Q_UINT16>(FSrcBlue * UINT16_MAX + 0.5);
+
+ dst[PIXEL_RED] = UINT16_BLEND(srcRed, dstRed, srcBlend);
+ dst[PIXEL_GREEN] = UINT16_BLEND(srcGreen, dstGreen, srcBlend);
+ dst[PIXEL_BLUE] = UINT16_BLEND(srcBlue, dstBlue, srcBlend);
+ }
+
+ COMMON_COMPOSITE_OP_EPILOG();
+}
+
+void KisRgbU16ColorSpace::compositeValue(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, Q_UINT16 opacity)
+{
+ COMMON_COMPOSITE_OP_PROLOG();
+
+ {
+ float FSrcRed = static_cast<float>(src[PIXEL_RED]) / UINT16_MAX;
+ float FSrcGreen = static_cast<float>(src[PIXEL_GREEN]) / UINT16_MAX;
+ float FSrcBlue = static_cast<float>(src[PIXEL_BLUE]) / UINT16_MAX;
+
+ Q_UINT16 dstRed = dst[PIXEL_RED];
+ Q_UINT16 dstGreen = dst[PIXEL_GREEN];
+ Q_UINT16 dstBlue = dst[PIXEL_BLUE];
+
+ float FDstRed = static_cast<float>(dstRed) / UINT16_MAX;
+ float FDstGreen = static_cast<float>(dstGreen) / UINT16_MAX;
+ float FDstBlue = static_cast<float>(dstBlue) / UINT16_MAX;
+
+ float srcHue;
+ float srcSaturation;
+ float srcValue;
+
+ float dstHue;
+ float dstSaturation;
+ float dstValue;
+
+ RGBToHSV(FSrcRed, FSrcGreen, FSrcBlue, &srcHue, &srcSaturation, &srcValue);
+ RGBToHSV(FDstRed, FDstGreen, FDstBlue, &dstHue, &dstSaturation, &dstValue);
+
+ HSVToRGB(dstHue, dstSaturation, srcValue, &FSrcRed, &FSrcGreen, &FSrcBlue);
+
+ Q_UINT16 srcRed = static_cast<Q_UINT16>(FSrcRed * UINT16_MAX + 0.5);
+ Q_UINT16 srcGreen = static_cast<Q_UINT16>(FSrcGreen * UINT16_MAX + 0.5);
+ Q_UINT16 srcBlue = static_cast<Q_UINT16>(FSrcBlue * UINT16_MAX + 0.5);
+
+ dst[PIXEL_RED] = UINT16_BLEND(srcRed, dstRed, srcBlend);
+ dst[PIXEL_GREEN] = UINT16_BLEND(srcGreen, dstGreen, srcBlend);
+ dst[PIXEL_BLUE] = UINT16_BLEND(srcBlue, dstBlue, srcBlend);
+ }
+
+ COMMON_COMPOSITE_OP_EPILOG();
+}
+
+void KisRgbU16ColorSpace::compositeColor(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, Q_UINT16 opacity)
+{
+ COMMON_COMPOSITE_OP_PROLOG();
+
+ {
+ float FSrcRed = static_cast<float>(src[PIXEL_RED]) / UINT16_MAX;
+ float FSrcGreen = static_cast<float>(src[PIXEL_GREEN]) / UINT16_MAX;
+ float FSrcBlue = static_cast<float>(src[PIXEL_BLUE]) / UINT16_MAX;
+
+ Q_UINT16 dstRed = dst[PIXEL_RED];
+ Q_UINT16 dstGreen = dst[PIXEL_GREEN];
+ Q_UINT16 dstBlue = dst[PIXEL_BLUE];
+
+ float FDstRed = static_cast<float>(dstRed) / UINT16_MAX;
+ float FDstGreen = static_cast<float>(dstGreen) / UINT16_MAX;
+ float FDstBlue = static_cast<float>(dstBlue) / UINT16_MAX;
+
+ float srcHue;
+ float srcSaturation;
+ float srcLightness;
+
+ float dstHue;
+ float dstSaturation;
+ float dstLightness;
+
+ RGBToHSL(FSrcRed, FSrcGreen, FSrcBlue, &srcHue, &srcSaturation, &srcLightness);
+ RGBToHSL(FDstRed, FDstGreen, FDstBlue, &dstHue, &dstSaturation, &dstLightness);
+
+ HSLToRGB(srcHue, srcSaturation, dstLightness, &FSrcRed, &FSrcGreen, &FSrcBlue);
+
+ Q_UINT16 srcRed = static_cast<Q_UINT16>(FSrcRed * UINT16_MAX + 0.5);
+ Q_UINT16 srcGreen = static_cast<Q_UINT16>(FSrcGreen * UINT16_MAX + 0.5);
+ Q_UINT16 srcBlue = static_cast<Q_UINT16>(FSrcBlue * UINT16_MAX + 0.5);
+
+ dst[PIXEL_RED] = UINT16_BLEND(srcRed, dstRed, srcBlend);
+ dst[PIXEL_GREEN] = UINT16_BLEND(srcGreen, dstGreen, srcBlend);
+ dst[PIXEL_BLUE] = UINT16_BLEND(srcBlue, dstBlue, srcBlend);
+ }
+
+ COMMON_COMPOSITE_OP_EPILOG();
+}
+
+void KisRgbU16ColorSpace::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,
+ Q_UINT16 /*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++)
+ {
+ Q_UINT16 srcAlpha = s->alpha;
+
+ // apply the alphamask
+ if (mask != 0) {
+ Q_UINT8 U8_mask = *mask;
+
+ if (U8_mask != OPACITY_OPAQUE) {
+ srcAlpha = UINT16_BLEND(srcAlpha, U16_OPACITY_OPAQUE, UINT8_TO_UINT16(U8_mask));
+ }
+ mask++;
+ }
+ d->alpha = UINT16_MULT(srcAlpha, d->alpha);
+ }
+
+ dst += dstRowSize;
+ src += srcRowSize;
+ if(srcAlphaMask) {
+ srcAlphaMask += maskRowStride;
+ }
+ }
+}
+
+void KisRgbU16ColorSpace::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)
+{
+ Q_UINT16 opacity = UINT8_TO_UINT16(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_IN:
+ //compositeIn(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ case COMPOSITE_OUT:
+ //compositeOut(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_ATOP:
+ //compositeAtop(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_XOR:
+ //compositeXor(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_PLUS:
+ //compositePlus(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_MINUS:
+ //compositeMinus(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_ADD:
+ //compositeAdd(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_SUBTRACT:
+ //compositeSubtract(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_DIFF:
+ //compositeDiff(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_MULT:
+ compositeMultiply(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_DIVIDE:
+ compositeDivide(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_BUMPMAP:
+ //compositeBumpmap(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_COPY:
+ compositeCopy(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, U8_opacity);
+ break;
+ case COMPOSITE_COPY_RED:
+ //compositeCopyRed(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_COPY_GREEN:
+ //compositeCopyGreen(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_COPY_BLUE:
+ //compositeCopyBlue(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_COPY_OPACITY:
+ //compositeCopyOpacity(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_CLEAR:
+ //compositeClear(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_DISSOLVE:
+ //compositeDissolve(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_DISPLACE:
+ //compositeDisplace(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ break;
+#if 0
+ case COMPOSITE_MODULATE:
+ compositeModulate(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_THRESHOLD:
+ compositeThreshold(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ break;
+#endif
+ case COMPOSITE_NO:
+ // No composition.
+ break;
+ case COMPOSITE_DARKEN:
+ compositeDarken(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_LIGHTEN:
+ compositeLighten(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_HUE:
+ compositeHue(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_SATURATION:
+ compositeSaturation(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_VALUE:
+ compositeValue(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_COLOR:
+ compositeColor(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_COLORIZE:
+ //compositeColorize(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_LUMINIZE:
+ //compositeLuminize(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_SCREEN:
+ compositeScreen(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_OVERLAY:
+ compositeOverlay(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_ERASE:
+ compositeErase(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_DODGE:
+ compositeDodge(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_BURN:
+ compositeBurn(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
+ break;
+ case COMPOSITE_ALPHA_DARKEN:
+ abstractCompositeAlphaDarken<Q_UINT16, U16Mult, Uint8ToU16, U16OpacityTest,
+ PIXEL_ALPHA, MAX_CHANNEL_RGB, MAX_CHANNEL_RGBA>(
+ dst, dstRowStride, src, srcRowStride, mask, maskRowStride,
+ rows, cols, opacity, U16Mult(), Uint8ToU16(), U16OpacityTest());
+ break;
+ default:
+ break;
+ }
+}
+
+KisCompositeOpList KisRgbU16ColorSpace::userVisiblecompositeOps() const
+{
+ KisCompositeOpList list;
+
+ list.append(KisCompositeOp(COMPOSITE_OVER));
+ list.append(KisCompositeOp(COMPOSITE_ALPHA_DARKEN));
+ list.append(KisCompositeOp(COMPOSITE_MULT));
+ list.append(KisCompositeOp(COMPOSITE_BURN));
+ list.append(KisCompositeOp(COMPOSITE_DODGE));
+ list.append(KisCompositeOp(COMPOSITE_DIVIDE));
+ list.append(KisCompositeOp(COMPOSITE_SCREEN));
+ list.append(KisCompositeOp(COMPOSITE_OVERLAY));
+ list.append(KisCompositeOp(COMPOSITE_DARKEN));
+ list.append(KisCompositeOp(COMPOSITE_LIGHTEN));
+ list.append(KisCompositeOp(COMPOSITE_HUE));
+ list.append(KisCompositeOp(COMPOSITE_SATURATION));
+ list.append(KisCompositeOp(COMPOSITE_VALUE));
+ list.append(KisCompositeOp(COMPOSITE_COLOR));
+
+ return list;
+}
diff --git a/krita/colorspaces/rgb_u16/kis_rgb_u16_colorspace.h b/krita/colorspaces/rgb_u16/kis_rgb_u16_colorspace.h
new file mode 100644
index 00000000..73a79eb3
--- /dev/null
+++ b/krita/colorspaces/rgb_u16/kis_rgb_u16_colorspace.h
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
+ * Copyright (c) 2005 Adrian Page <adrian@pagenet.plus.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_STRATEGY_COLORSPACE_RGB_U16_H_
+#define KIS_STRATEGY_COLORSPACE_RGB_U16_H_
+
+#include <klocale.h>
+
+#include <koffice_export.h>
+
+#include "kis_global.h"
+#include "kis_u16_base_colorspace.h"
+#include "kis_integer_maths.h"
+
+
+class KRITATOOL_EXPORT KisRgbU16ColorSpace : public KisU16BaseColorSpace {
+public:
+
+ struct Pixel {
+ Q_UINT16 blue;
+ Q_UINT16 green;
+ Q_UINT16 red;
+ Q_UINT16 alpha;
+ };
+public:
+ KisRgbU16ColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p);
+ virtual ~KisRgbU16ColorSpace();
+
+ virtual bool willDegrade(ColorSpaceIndependence independence)
+ {
+ if (independence == TO_RGBA8)
+ return true;
+ else
+ return false;
+ };
+
+
+
+public:
+ void setPixel(Q_UINT8 *pixel, Q_UINT16 red, Q_UINT16 green, Q_UINT16 blue, Q_UINT16 alpha) const;
+ void getPixel(const Q_UINT8 *pixel, Q_UINT16 *red, Q_UINT16 *green, Q_UINT16 *blue, Q_UINT16 *alpha) const;
+
+ virtual void mixColors(const Q_UINT8 **colors, const Q_UINT8 *weights, Q_UINT32 nColors, Q_UINT8 *dst) const;
+ virtual void convolveColors(Q_UINT8** colors, Q_INT32* kernelValues, KisChannelInfo::enumChannelFlags channelFlags, Q_UINT8 *dst, Q_INT32 factor, Q_INT32 offset, Q_INT32 nColors) const;
+ virtual void invertColor(Q_UINT8 * src, Q_INT32 nPixels);
+ virtual Q_UINT8 intensity8(const Q_UINT8 * src) const;
+
+ virtual QValueVector<KisChannelInfo *> channels() const;
+ virtual Q_UINT32 nChannels() const;
+ virtual Q_UINT32 nColorChannels() const;
+ virtual Q_UINT32 pixelSize() const;
+
+ 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, Q_UINT16 opacity);
+ void compositeMultiply(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, Q_UINT16 opacity);
+ void compositeDivide(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, Q_UINT16 opacity);
+ void compositeScreen(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, Q_UINT16 opacity);
+ void compositeOverlay(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, Q_UINT16 opacity);
+ void compositeDodge(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, Q_UINT16 opacity);
+ void compositeBurn(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, Q_UINT16 opacity);
+ void compositeDarken(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, Q_UINT16 opacity);
+ void compositeLighten(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, Q_UINT16 opacity);
+ void compositeHue(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, Q_UINT16 opacity);
+ void compositeSaturation(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, Q_UINT16 opacity);
+ void compositeValue(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, Q_UINT16 opacity);
+ void compositeColor(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, Q_UINT16 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, Q_UINT16 opacity);
+
+private:
+ friend class KisRgbU16ColorSpaceTester;
+
+ static const Q_UINT8 PIXEL_BLUE = 0;
+ static const Q_UINT8 PIXEL_GREEN = 1;
+ static const Q_UINT8 PIXEL_RED = 2;
+ static const Q_UINT8 PIXEL_ALPHA = 3;
+};
+
+class KisRgbU16ColorSpaceFactory : public KisColorSpaceFactory
+{
+public:
+ /**
+ * Krita definition for use in .kra files and internally: unchanging name +
+ * i18n'able description.
+ */
+ virtual KisID id() const { return KisID("RGBA16", i18n("RGB (16-bit integer/channel)")); };
+
+ /**
+ * lcms colorspace type definition.
+ */
+ virtual Q_UINT32 colorSpaceType() { return TYPE_BGRA_16; };
+
+ virtual icColorSpaceSignature colorSpaceSignature() { return icSigRgbData; };
+
+ virtual KisColorSpace *createColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p) { return new KisRgbU16ColorSpace(parent, p); };
+
+ virtual QString defaultProfile() { return "sRGB built-in - (lcms internal)"; };
+};
+
+#endif // KIS_STRATEGY_COLORSPACE_RGB_U16_H_
diff --git a/krita/colorspaces/rgb_u16/krita_rgb_u16_plugin.desktop b/krita/colorspaces/rgb_u16/krita_rgb_u16_plugin.desktop
new file mode 100644
index 00000000..4cf76766
--- /dev/null
+++ b/krita/colorspaces/rgb_u16/krita_rgb_u16_plugin.desktop
@@ -0,0 +1,80 @@
+[Desktop Entry]
+Name=RGB Color Model (16-bit integer)
+Name[bg]=Цветови модел RGB (16 бита)
+Name[ca]=Model de color RGB (enter de 16 bits)
+Name[cy]=Model Lliw RGB (cyfanrif 16-did)
+Name[da]=RGB-farvemodel (16-bit heltal)
+Name[de]=RGB-Farbmodell (16-bit Ganzzahl)
+Name[el]=Χρωματικό μοντέλο RGB (16 bit ακέραιοι)
+Name[en_GB]=RGB Colour Model (16-bit integer)
+Name[eo]=RGB-kolormodelo (16-bita entjero)
+Name[es]=Modelo de color RGB (entero de 16 bits)
+Name[et]=RGB värvimudel (16-bitine täisarv)
+Name[fa]=مدل رنگ RGB )عدد صحیح ۱۶ بیتی(
+Name[fr]=Modèle de couleurs RVB (entiers 16 bits)
+Name[fy]=RGB-kleurmodel (16-bit integer)
+Name[gl]=Modelo de Cores RGB (inteiros de 16-bit)
+Name[he]=מודל צבעים RGB (16 סיביות)
+Name[hu]=RGB színmodell (16 bites egész)
+Name[is]=RGB litategund (16-bita heiltala)
+Name[it]=Modello di colore RGB (intero a 16 bit)
+Name[ja]=RGB カラーモデル (16 ビット整数)
+Name[km]=គំរូ​ពណ៌ RGB (ចំនួនគត់ 16 ប៊ីត)
+Name[lt]=RGB spalvų modelis (16-bitų sveikasis)
+Name[nb]=RGB-fargemodell (16-bit heltall)
+Name[nds]=RGB-Klöörmodell (16-Bit Heeltall)
+Name[ne]=RGB रङ मोडेल (१६-बिट इन्टिजर)
+Name[nl]=RGB-kleurmodel (16-bit integer)
+Name[pl]=Przestrzeń barw RGB (16-bitowa liczba całkowita)
+Name[pt]=Modelo de Cor RGB (inteiro de 16-bits)
+Name[pt_BR]=Modelo de Cor RGB (inteiro de 16-bits)
+Name[ru]=RGB (целое 16-бит)
+Name[sk]=Model farieb RGB (16-bitové čísla)
+Name[sl]=Barvni model RGB (16-bitno celo število)
+Name[sr]=RGB модел боја (16-битно целобројно)
+Name[sr@Latn]=RGB model boja (16-bitno celobrojno)
+Name[sv]=RGB-färgmodell (16-bitars heltal)
+Name[uk]=Модель кольору RGB (16-бітне ціле число)
+Name[uz]=RGB rang usuli (16-bit butun)
+Name[uz@cyrillic]=RGB ранг усули (16-бит бутун)
+Name[zh_TW]=RGB 色彩模型 (16-bit 整數)
+Comment=Color model for 16-bit integer per channel RGB images
+Comment[bg]=Цветови модел за 16 битови изображения RGB
+Comment[ca]=Model de color enter de 16 bits per canal d'imatges RGB
+Comment[cy]=Model lliw ar gyfer delweddau RGB â chyfanrif 16-did/sianel
+Comment[da]=Farvemodel for 16-bit heltal pr kanal RGB-billeder
+Comment[de]=Farbmodell für 16-bit Ganzzahl pro Kanal RGB-Bilder
+Comment[el]=Χρωματικό μοντέλο για 16-bit ακέραιους ανά κανάλι RGB εικόνες
+Comment[en_GB]=Colour model for 16-bit integer per channel RGB images
+Comment[es]=Modelo de color de entero de 16 bits por canal para imágenes RGB
+Comment[et]=16-bitiste täisarvuliste kanalitega RGB-piltide värvimudel
+Comment[fa]=مدل رنگ برای عدد صحیح ۱۶ بیتی برای هر تصویر RGB مجرا
+Comment[fr]=Modèle de couleurs pour des images RVB en 16 bits/plage
+Comment[fy]=Kleurmodel foar RGB-ôfbyldings mei16-bit/kanaal
+Comment[gl]=Modelo de cores para imaxes RGB de inteiro de 16-bit por canal
+Comment[he]=מודל צבעים עבור תמונות RGB של 16 סיביות/ערוצים
+Comment[hu]=Színmodell 16 bites egész/csatorna RGB képekhez
+Comment[is]=Litategund fyrir 16-bita heiltölu á rás RGB myndir
+Comment[it]=Modello di colore per immagini RGB in interi a canale di 16 bit
+Comment[ja]=16 ビット整数/チャンネル RGB 画像のためのカラーモデル
+Comment[km]=គំរូ​ពណ៌​សម្រាប់​រូបភាព RGB ចំនួនគត់ 16 ប៊ីត​ក្នុង​មួយ​ឆានែល
+Comment[nb]=Fargemodell for RGB-bilde med 16 bit heltall per kanal
+Comment[nds]=Klöörmodell för RGB-Biller mit 16-Bit Heeltall per Kanaal
+Comment[ne]=प्रति च्यानल RGB छविहरूको १६-बिट इन्टिजरका लागि रङ मोडेल
+Comment[nl]=Kleurmodel voor RGB-afbeeldingen met 16-bit/kanaal
+Comment[pl]=Przestrzeń barw dla obrazków RGB o 16-bitowych liczbach całkowitych na kanał
+Comment[pt]=Modelo de cor para imagens RGB com 16 bits por canal
+Comment[pt_BR]=Modelo de cor para imagens RGB com 16 bits por canal
+Comment[ru]=Цветовое пространство RGB (целое 16-бит/канал)
+Comment[sk]=Model farieb pre RGB obrázky so 16-bitovými číslami na kanál
+Comment[sl]=Barvni model za slike RGB s 16-bitnim celim številom na kanal
+Comment[sr]=Модел боја за RGB слике, 16-битно целобројно по каналу
+Comment[sr@Latn]=Model boja za RGB slike, 16-bitno celobrojno po kanalu
+Comment[sv]=Färgmodell för 16-bitars heltal/kanal RGB-bilder
+Comment[uk]=Модель кольорів для зображень RGB 32-біт ціле число на канал
+Comment[zh_TW]=每色頻 16-bit 整數 RGB 圖片的色彩模型
+ServiceTypes=Krita/ColorSpace
+Type=Service
+X-KDE-Library=krita_rgb_u16_plugin
+X-Krita-Version=2
+
diff --git a/krita/colorspaces/rgb_u16/rgb_u16_plugin.cc b/krita/colorspaces/rgb_u16/rgb_u16_plugin.cc
new file mode 100644
index 00000000..0f88b158
--- /dev/null
+++ b/krita/colorspaces/rgb_u16/rgb_u16_plugin.cc
@@ -0,0 +1,61 @@
+/*
+* rgb_u16_plugin.cc -- Part of Krita
+*
+* Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org)
+* Copyright (c) 2005 Adrian Page <adrian@pagenet.plus.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 <kinstance.h>
+#include <kgenericfactory.h>
+#include <kdebug.h>
+
+#include <kis_debug_areas.h>
+#include <kis_colorspace_factory_registry.h>
+
+#include "rgb_u16_plugin.h"
+#include "kis_rgb_u16_colorspace.h"
+#include "kis_basic_histogram_producers.h"
+
+typedef KGenericFactory<RGBU16Plugin> RGBU16PluginFactory;
+K_EXPORT_COMPONENT_FACTORY( krita_rgb_u16_plugin, RGBU16PluginFactory( "krita" ) )
+
+
+RGBU16Plugin::RGBU16Plugin(QObject *parent, const char *name, const QStringList &)
+ : KParts::Plugin(parent, name)
+{
+ setInstance(RGBU16PluginFactory::instance());
+
+ if ( parent->inherits("KisColorSpaceFactoryRegistry") )
+ {
+ KisColorSpaceFactoryRegistry * f = dynamic_cast<KisColorSpaceFactoryRegistry *>( parent );
+
+ KisColorSpace * colorSpaceRGBU16 = new KisRgbU16ColorSpace(f, 0);
+ KisColorSpaceFactory * csFactory = new KisRgbU16ColorSpaceFactory();
+ f->add( csFactory );
+
+ KisHistogramProducerFactoryRegistry::instance()->add(
+ new KisBasicHistogramProducerFactory<KisBasicU16HistogramProducer>
+ (KisID("RGB16HISTO", i18n("RGB16")), colorSpaceRGBU16) );
+ }
+
+}
+
+RGBU16Plugin::~RGBU16Plugin()
+{
+}
+
+#include "rgb_u16_plugin.moc"
diff --git a/krita/colorspaces/rgb_u16/rgb_u16_plugin.h b/krita/colorspaces/rgb_u16/rgb_u16_plugin.h
new file mode 100644
index 00000000..643833ce
--- /dev/null
+++ b/krita/colorspaces/rgb_u16/rgb_u16_plugin.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2003 Boudewijn Rempt (boud@valdyas.org)
+ *
+ * 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 RGB_U16_PLUGIN_H_
+#define RGB_U16_PLUGIN_H_
+
+#include <kparts/plugin.h>
+
+/**
+ * A plugin wrapper around the RGB U16 colour space strategy.
+ */
+class RGBU16Plugin : public KParts::Plugin
+{
+ Q_OBJECT
+public:
+ RGBU16Plugin(QObject *parent, const char *name, const QStringList &);
+ virtual ~RGBU16Plugin();
+};
+
+
+#endif // RGB_U16_PLUGIN_H_
diff --git a/krita/colorspaces/rgb_u16/tests/Makefile.am b/krita/colorspaces/rgb_u16/tests/Makefile.am
new file mode 100644
index 00000000..f8c8dc36
--- /dev/null
+++ b/krita/colorspaces/rgb_u16/tests/Makefile.am
@@ -0,0 +1,17 @@
+AM_CPPFLAGS = -I$(srcdir)/.. \
+ -I$(srcdir)/../../../sdk \
+ -I$(srcdir)/../../../kritacolor/color_strategy/ \
+ -I$(srcdir)/../../../color_strategy/ \
+ $(all_includes)
+
+# The check_ target makes sure we don't install the modules,
+# $(KDE_CHECK_PLUGIN) assures a shared library is created.
+check_LTLIBRARIES = kunittest_kis_strategy_colorspace_rgb_u16_tester.la
+
+kunittest_kis_strategy_colorspace_rgb_u16_tester_la_SOURCES = kis_strategy_colorspace_rgb_u16_tester.cc
+kunittest_kis_strategy_colorspace_rgb_u16_tester_la_LIBADD = -lkunittest ../libkrita_rgb_u16.la
+kunittest_kis_strategy_colorspace_rgb_u16_tester_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) $(all_libraries)
+
+check-local: kunittest_kis_strategy_colorspace_rgb_u16_tester.la
+ kunittestmodrunner
+
diff --git a/krita/colorspaces/rgb_u16/tests/kis_strategy_colorspace_rgb_u16_tester.cc b/krita/colorspaces/rgb_u16/tests/kis_strategy_colorspace_rgb_u16_tester.cc
new file mode 100644
index 00000000..b41d46bc
--- /dev/null
+++ b/krita/colorspaces/rgb_u16/tests/kis_strategy_colorspace_rgb_u16_tester.cc
@@ -0,0 +1,524 @@
+/*
+ * Copyright (c) 2005 Adrian Page <adrian@pagenet.plus.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 <kunittest/runner.h>
+#include <kunittest/module.h>
+
+#include "kis_factory.h"
+#include "kis_strategy_colorspace_rgb_u16_tester.h"
+#include "kis_rgb_u16_colorspace.h"
+#include "kis_integer_maths.h"
+#include "kis_paint_device.h"
+
+using namespace KUnitTest;
+
+KUNITTEST_MODULE( kunittest_kis_strategy_colorspace_rgb_u16_tester, "RGB 16-bit integer colorspace tester" );
+KUNITTEST_MODULE_REGISTER_TESTER( KisRgbU16ColorSpaceTester );
+
+#define PIXEL_BLUE 0
+#define PIXEL_GREEN 1
+#define PIXEL_RED 2
+#define PIXEL_ALPHA 3
+
+#define NUM_CHANNELS 4
+#define NUM_COLOUR_CHANNELS 3
+#define CHANNEL_SIZE 2
+
+#define RED_CHANNEL 0
+#define GREEN_CHANNEL 1
+#define BLUE_CHANNEL 2
+#define ALPHA_CHANNEL 3
+
+#define MAX_CHANNEL_VALUE UINT16_MAX
+#define MIN_CHANNEL_VALUE UINT16_MIN
+
+void KisRgbU16ColorSpaceTester::allTests()
+{
+ // We need this so that the colour profile loading can operate without crashing.
+ KisFactory *factory = new KisFactory();
+
+ testBasics();
+ testToQImage();
+ testCompositeOps();
+ testMixColors();
+
+ delete factory;
+}
+
+void KisRgbU16ColorSpaceTester::testBasics()
+{
+ KisProfile *defProfile = new KisProfile(cmsCreate_sRGBProfile());
+
+ KisRgbU16ColorSpace *cs = new KisRgbU16ColorSpace(defProfile);
+ KisAbstractColorSpace * csSP = cs;
+
+ CHECK(cs->hasAlpha(), true);
+ CHECK(cs->nChannels(), NUM_CHANNELS);
+ CHECK(cs->nColorChannels(), NUM_COLOUR_CHANNELS);
+ CHECK(cs->pixelSize(), NUM_CHANNELS * CHANNEL_SIZE);
+
+ QValueVector<KisChannelInfo *> channels = cs->channels();
+
+ // Red
+ CHECK(channels[0]->pos(), PIXEL_RED * CHANNEL_SIZE);
+ CHECK(channels[0]->size(), CHANNEL_SIZE);
+ CHECK(channels[0]->channelType(), COLOR);
+
+ // Green
+ CHECK(channels[1]->pos(), PIXEL_GREEN * CHANNEL_SIZE);
+ CHECK(channels[1]->size(), CHANNEL_SIZE);
+ CHECK(channels[1]->channelType(), COLOR);
+
+ // Blue
+ CHECK(channels[2]->pos(), PIXEL_BLUE * CHANNEL_SIZE);
+ CHECK(channels[2]->size(), CHANNEL_SIZE);
+ CHECK(channels[2]->channelType(), COLOR);
+
+ // Alpha
+ CHECK(channels[3]->pos(), PIXEL_ALPHA * CHANNEL_SIZE);
+ CHECK(channels[3]->size(), CHANNEL_SIZE);
+ CHECK(channels[3]->channelType(), ALPHA);
+
+ KisPaintDeviceSP pd = new KisPaintDevice(cs, "test");
+
+ KisRgbU16ColorSpace::Pixel defaultPixel;
+
+ memcpy(&defaultPixel, pd->dataManager()->defaultPixel(), sizeof(defaultPixel));
+
+ CHECK((int)defaultPixel.red, 0);
+ CHECK((int)defaultPixel.green, 0);
+ CHECK((int)defaultPixel.blue, 0);
+ CHECK((int)defaultPixel.alpha, 0);
+
+ Q_UINT16 pixel[NUM_CHANNELS];
+
+ cs->fromQColor(qRgb(255, 255, 255), reinterpret_cast<Q_UINT8 *>(pixel));
+
+ CHECK((uint)pixel[PIXEL_RED], MAX_CHANNEL_VALUE);
+ CHECK((uint)pixel[PIXEL_GREEN], MAX_CHANNEL_VALUE);
+ CHECK((uint)pixel[PIXEL_BLUE], MAX_CHANNEL_VALUE);
+
+ cs->fromQColor(qRgb(0, 0, 0), reinterpret_cast<Q_UINT8 *>(pixel));
+
+ CHECK((uint)pixel[PIXEL_RED], MIN_CHANNEL_VALUE);
+ CHECK((uint)pixel[PIXEL_GREEN], MIN_CHANNEL_VALUE);
+ CHECK((uint)pixel[PIXEL_BLUE], MIN_CHANNEL_VALUE);
+
+ cs->fromQColor(qRgb(128, 64, 192), reinterpret_cast<Q_UINT8 *>(pixel));
+
+ CHECK((uint)pixel[PIXEL_RED], (uint)UINT8_TO_UINT16(128));
+ CHECK((uint)pixel[PIXEL_GREEN], (uint)UINT8_TO_UINT16(64));
+ CHECK((uint)pixel[PIXEL_BLUE], (uint)UINT8_TO_UINT16(192));
+
+ cs->fromQColor(qRgb(255, 255, 255), OPACITY_OPAQUE, reinterpret_cast<Q_UINT8 *>(pixel));
+
+ CHECK((uint)pixel[PIXEL_RED], MAX_CHANNEL_VALUE);
+ CHECK((uint)pixel[PIXEL_GREEN], MAX_CHANNEL_VALUE);
+ CHECK((uint)pixel[PIXEL_BLUE], MAX_CHANNEL_VALUE);
+ CHECK((uint)pixel[PIXEL_ALPHA], MAX_CHANNEL_VALUE);
+
+ cs->fromQColor(qRgb(255, 255, 255), OPACITY_TRANSPARENT, reinterpret_cast<Q_UINT8 *>(pixel));
+
+ CHECK((uint)pixel[PIXEL_RED], MAX_CHANNEL_VALUE);
+ CHECK((uint)pixel[PIXEL_GREEN], MAX_CHANNEL_VALUE);
+ CHECK((uint)pixel[PIXEL_BLUE], MAX_CHANNEL_VALUE);
+ CHECK((uint)pixel[PIXEL_ALPHA], MIN_CHANNEL_VALUE);
+
+ cs->fromQColor(qRgb(255, 255, 255), OPACITY_OPAQUE / 2, reinterpret_cast<Q_UINT8 *>(pixel));
+
+ CHECK((uint)pixel[PIXEL_RED], MAX_CHANNEL_VALUE);
+ CHECK((uint)pixel[PIXEL_GREEN], MAX_CHANNEL_VALUE);
+ CHECK((uint)pixel[PIXEL_BLUE], MAX_CHANNEL_VALUE);
+ CHECK((uint)pixel[PIXEL_ALPHA], UINT8_TO_UINT16(OPACITY_OPAQUE / 2));
+
+ pixel[PIXEL_RED] = MAX_CHANNEL_VALUE;
+ pixel[PIXEL_GREEN] = MAX_CHANNEL_VALUE;
+ pixel[PIXEL_BLUE] = MAX_CHANNEL_VALUE;
+
+ QColor c;
+
+ cs->toQColor(reinterpret_cast<const Q_UINT8 *>(pixel), &c);
+
+ CHECK(c.red(), 255);
+ CHECK(c.green(), 255);
+ CHECK(c.blue(), 255);
+
+ pixel[PIXEL_RED] = MIN_CHANNEL_VALUE;
+ pixel[PIXEL_GREEN] = MIN_CHANNEL_VALUE;
+ pixel[PIXEL_BLUE] = MIN_CHANNEL_VALUE;
+
+ cs->toQColor(reinterpret_cast<const Q_UINT8 *>(pixel), &c);
+
+ CHECK(c.red(), 0);
+ CHECK(c.green(), 0);
+ CHECK(c.blue(), 0);
+
+ pixel[PIXEL_RED] = MAX_CHANNEL_VALUE / 4;
+ pixel[PIXEL_GREEN] = MAX_CHANNEL_VALUE / 2;
+ pixel[PIXEL_BLUE] = (3 * MAX_CHANNEL_VALUE) / 4;
+
+ cs->toQColor(reinterpret_cast<const Q_UINT8 *>(pixel), &c);
+
+ CHECK(c.red(), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE / 4));
+ CHECK(c.green(), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE / 2));
+ CHECK(c.blue(), (int)UINT16_TO_UINT8((3 * MAX_CHANNEL_VALUE) / 4));
+
+ pixel[PIXEL_RED] = MAX_CHANNEL_VALUE;
+ pixel[PIXEL_GREEN] = MAX_CHANNEL_VALUE;
+ pixel[PIXEL_BLUE] = MAX_CHANNEL_VALUE;
+ pixel[PIXEL_ALPHA] = MAX_CHANNEL_VALUE;
+
+ Q_UINT8 opacity;
+
+ cs->toQColor(reinterpret_cast<const Q_UINT8 *>(pixel), &c, &opacity);
+
+ CHECK(c.red(), 255);
+ CHECK(c.green(), 255);
+ CHECK(c.blue(), 255);
+ CHECK(opacity, OPACITY_OPAQUE);
+
+ pixel[PIXEL_ALPHA] = MAX_CHANNEL_VALUE;
+
+ cs->toQColor(reinterpret_cast<const Q_UINT8 *>(pixel), &c, &opacity);
+
+ CHECK(c.red(), 255);
+ CHECK(c.green(), 255);
+ CHECK(c.blue(), 255);
+ CHECK(opacity, OPACITY_OPAQUE);
+
+ pixel[PIXEL_RED] = MIN_CHANNEL_VALUE;
+ pixel[PIXEL_GREEN] = MIN_CHANNEL_VALUE;
+ pixel[PIXEL_BLUE] = MIN_CHANNEL_VALUE;
+ pixel[PIXEL_ALPHA] = MIN_CHANNEL_VALUE;
+
+ cs->toQColor(reinterpret_cast<const Q_UINT8 *>(pixel), &c, &opacity);
+
+ CHECK(c.red(), 0);
+ CHECK(c.green(), 0);
+ CHECK(c.blue(), 0);
+ CHECK(opacity, OPACITY_TRANSPARENT);
+
+ pixel[PIXEL_RED] = MAX_CHANNEL_VALUE / 4;
+ pixel[PIXEL_GREEN] = MAX_CHANNEL_VALUE / 2;
+ pixel[PIXEL_BLUE] = (3 * MAX_CHANNEL_VALUE) / 4;
+ pixel[PIXEL_ALPHA] = MAX_CHANNEL_VALUE / 2;
+
+ cs->toQColor(reinterpret_cast<const Q_UINT8 *>(pixel), &c, &opacity);
+
+ CHECK(c.red(), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE / 4));
+ CHECK(c.green(), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE / 2));
+ CHECK(c.blue(), (int)UINT16_TO_UINT8((3 * MAX_CHANNEL_VALUE) / 4));
+ CHECK((int)opacity, (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE / 2));
+
+ #define NUM_PIXELS 4
+
+ KisRgbU16ColorSpace::Pixel pixels[NUM_PIXELS] = {
+ {MAX_CHANNEL_VALUE, MAX_CHANNEL_VALUE, MAX_CHANNEL_VALUE, MAX_CHANNEL_VALUE / 4},
+ {MAX_CHANNEL_VALUE / 4, MAX_CHANNEL_VALUE / 2, MAX_CHANNEL_VALUE / 3, MAX_CHANNEL_VALUE / 2},
+ {MAX_CHANNEL_VALUE, MAX_CHANNEL_VALUE, MAX_CHANNEL_VALUE, MIN_CHANNEL_VALUE},
+ {MIN_CHANNEL_VALUE, MIN_CHANNEL_VALUE, MIN_CHANNEL_VALUE, MAX_CHANNEL_VALUE}
+ };
+
+ cs->setAlpha(reinterpret_cast<Q_UINT8 *>(pixels), OPACITY_OPAQUE / 2, NUM_PIXELS);
+
+ CHECK((uint)pixels[0].red, MAX_CHANNEL_VALUE);
+ CHECK((uint)pixels[0].green, MAX_CHANNEL_VALUE);
+ CHECK((uint)pixels[0].blue, MAX_CHANNEL_VALUE);
+ CHECK((uint)pixels[0].alpha, (uint)UINT8_TO_UINT16(OPACITY_OPAQUE / 2));
+
+ CHECK((uint)pixels[1].red, MAX_CHANNEL_VALUE / 3);
+ CHECK((uint)pixels[1].green, MAX_CHANNEL_VALUE / 2);
+ CHECK((uint)pixels[1].blue, MAX_CHANNEL_VALUE / 4);
+ CHECK((uint)pixels[1].alpha, (uint)UINT8_TO_UINT16(OPACITY_OPAQUE / 2));
+
+ CHECK((uint)pixels[2].red, MAX_CHANNEL_VALUE);
+ CHECK((uint)pixels[2].green, MAX_CHANNEL_VALUE);
+ CHECK((uint)pixels[2].blue, MAX_CHANNEL_VALUE);
+ CHECK((uint)pixels[2].alpha, (uint)UINT8_TO_UINT16(OPACITY_OPAQUE / 2));
+
+ CHECK((uint)pixels[3].red, MIN_CHANNEL_VALUE);
+ CHECK((uint)pixels[3].green, MIN_CHANNEL_VALUE);
+ CHECK((uint)pixels[3].blue, MIN_CHANNEL_VALUE);
+ CHECK((uint)pixels[3].alpha, (uint)UINT8_TO_UINT16(OPACITY_OPAQUE / 2));
+
+ pixel[PIXEL_RED] = MAX_CHANNEL_VALUE;
+ pixel[PIXEL_GREEN] = MAX_CHANNEL_VALUE / 2;
+ pixel[PIXEL_BLUE] = MAX_CHANNEL_VALUE / 4;
+ pixel[PIXEL_ALPHA] = MIN_CHANNEL_VALUE;
+
+ QString valueText = cs->channelValueText(reinterpret_cast<Q_UINT8 *>(pixel), RED_CHANNEL);
+ CHECK(valueText, QString().setNum(MAX_CHANNEL_VALUE));
+
+ valueText = cs->channelValueText(reinterpret_cast<Q_UINT8 *>(pixel), GREEN_CHANNEL);
+ CHECK(valueText, QString().setNum(MAX_CHANNEL_VALUE / 2));
+
+ valueText = cs->channelValueText(reinterpret_cast<Q_UINT8 *>(pixel), BLUE_CHANNEL);
+ CHECK(valueText, QString().setNum(MAX_CHANNEL_VALUE / 4));
+
+ valueText = cs->channelValueText(reinterpret_cast<Q_UINT8 *>(pixel), ALPHA_CHANNEL);
+ CHECK(valueText, QString().setNum(MIN_CHANNEL_VALUE));
+
+ valueText = cs->normalisedChannelValueText(reinterpret_cast<Q_UINT8 *>(pixel), RED_CHANNEL);
+ CHECK(valueText, QString().setNum(static_cast<float>(MAX_CHANNEL_VALUE) / MAX_CHANNEL_VALUE));
+
+ valueText = cs->normalisedChannelValueText(reinterpret_cast<Q_UINT8 *>(pixel), GREEN_CHANNEL);
+ CHECK(valueText, QString().setNum(static_cast<float>(MAX_CHANNEL_VALUE / 2) / MAX_CHANNEL_VALUE));
+
+ valueText = cs->normalisedChannelValueText(reinterpret_cast<Q_UINT8 *>(pixel), BLUE_CHANNEL);
+ CHECK(valueText, QString().setNum(static_cast<float>(MAX_CHANNEL_VALUE / 4) / MAX_CHANNEL_VALUE));
+
+ valueText = cs->normalisedChannelValueText(reinterpret_cast<Q_UINT8 *>(pixel), ALPHA_CHANNEL);
+ CHECK(valueText, QString().setNum(static_cast<float>(MIN_CHANNEL_VALUE) / MAX_CHANNEL_VALUE));
+
+ cs->setPixel(reinterpret_cast<Q_UINT8 *>(pixel), 128, 192, 64, 99);
+ CHECK((uint)pixel[PIXEL_RED], 128u);
+ CHECK((uint)pixel[PIXEL_GREEN], 192u);
+ CHECK((uint)pixel[PIXEL_BLUE], 64u);
+ CHECK((uint)pixel[PIXEL_ALPHA], 99u);
+
+ Q_UINT16 red;
+ Q_UINT16 green;
+ Q_UINT16 blue;
+ Q_UINT16 alpha;
+
+ cs->getPixel(reinterpret_cast<const Q_UINT8 *>(pixel), &red, &green, &blue, &alpha);
+ CHECK((uint)red, 128u);
+ CHECK((uint)green, 192u);
+ CHECK((uint)blue, 64u);
+ CHECK((uint)alpha, 99u);
+}
+
+void KisRgbU16ColorSpaceTester::testMixColors()
+{
+ KisProfile *defProfile = new KisProfile(cmsCreate_sRGBProfile());
+
+ KisAbstractColorSpace * cs = new KisRgbU16ColorSpace(defProfile);
+
+ // Test mixColors.
+ Q_UINT16 pixel1[NUM_CHANNELS];
+ Q_UINT16 pixel2[NUM_CHANNELS];
+ Q_UINT16 outputPixel[NUM_CHANNELS];
+
+ outputPixel[PIXEL_RED] = 0;
+ outputPixel[PIXEL_GREEN] = 0;
+ outputPixel[PIXEL_BLUE] = 0;
+ outputPixel[PIXEL_ALPHA] = 0;
+
+ pixel1[PIXEL_RED] = UINT16_MAX;
+ pixel1[PIXEL_GREEN] = UINT16_MAX;
+ pixel1[PIXEL_BLUE] = UINT16_MAX;
+ pixel1[PIXEL_ALPHA] = UINT16_MAX;
+
+ pixel2[PIXEL_RED] = 0;
+ pixel2[PIXEL_GREEN] = 0;
+ pixel2[PIXEL_BLUE] = 0;
+ pixel2[PIXEL_ALPHA] = 0;
+
+ const Q_UINT8 *pixelPtrs[2];
+ Q_UINT8 weights[2];
+
+ pixelPtrs[0] = reinterpret_cast<const Q_UINT8 *>(pixel1);
+ pixelPtrs[1] = reinterpret_cast<const Q_UINT8 *>(pixel2);
+
+ weights[0] = 255;
+ weights[1] = 0;
+
+ cs->mixColors(pixelPtrs, weights, 2, reinterpret_cast<Q_UINT8 *>(outputPixel));
+
+ CHECK((uint)outputPixel[PIXEL_RED], UINT16_MAX);
+ CHECK((uint)outputPixel[PIXEL_GREEN], UINT16_MAX);
+ CHECK((uint)outputPixel[PIXEL_BLUE], UINT16_MAX);
+ CHECK((uint)outputPixel[PIXEL_ALPHA], UINT16_MAX);
+
+ weights[0] = 0;
+ weights[1] = 255;
+
+ cs->mixColors(pixelPtrs, weights, 2, reinterpret_cast<Q_UINT8 *>(outputPixel));
+
+ CHECK((int)outputPixel[PIXEL_RED], 0);
+ CHECK((int)outputPixel[PIXEL_GREEN], 0);
+ CHECK((int)outputPixel[PIXEL_BLUE], 0);
+ CHECK((int)outputPixel[PIXEL_ALPHA], 0);
+
+ weights[0] = 128;
+ weights[1] = 127;
+
+ cs->mixColors(pixelPtrs, weights, 2, reinterpret_cast<Q_UINT8 *>(outputPixel));
+
+ CHECK((uint)outputPixel[PIXEL_RED], UINT16_MAX);
+ CHECK((uint)outputPixel[PIXEL_GREEN], UINT16_MAX);
+ CHECK((uint)outputPixel[PIXEL_BLUE], UINT16_MAX);
+ CHECK((uint)outputPixel[PIXEL_ALPHA], (128u * UINT16_MAX) / 255u);
+
+ pixel1[PIXEL_RED] = 20000;
+ pixel1[PIXEL_GREEN] = 10000;
+ pixel1[PIXEL_BLUE] = 5000;
+ pixel1[PIXEL_ALPHA] = UINT16_MAX;
+
+ pixel2[PIXEL_RED] = 10000;
+ pixel2[PIXEL_GREEN] = 20000;
+ pixel2[PIXEL_BLUE] = 2000;
+ pixel2[PIXEL_ALPHA] = UINT16_MAX;
+
+ cs->mixColors(pixelPtrs, weights, 2, reinterpret_cast<Q_UINT8 *>(outputPixel));
+
+ CHECK_TOLERANCE((uint)outputPixel[PIXEL_RED], (128u * 20000u + 127u * 10000u) / 255u, 5u);
+ CHECK_TOLERANCE((uint)outputPixel[PIXEL_GREEN], (128u * 10000u + 127u * 20000u) / 255u, 5u);
+ CHECK_TOLERANCE((uint)outputPixel[PIXEL_BLUE], (128u * 5000u + 127u * 2000u) / 255u, 5u);
+ CHECK((uint)outputPixel[PIXEL_ALPHA], UINT16_MAX);
+
+ pixel1[PIXEL_RED] = 0;
+ pixel1[PIXEL_GREEN] = 0;
+ pixel1[PIXEL_BLUE] = 0;
+ pixel1[PIXEL_ALPHA] = 0;
+
+ pixel2[PIXEL_RED] = UINT16_MAX;
+ pixel2[PIXEL_GREEN] = UINT16_MAX;
+ pixel2[PIXEL_BLUE] = UINT16_MAX;
+ pixel2[PIXEL_ALPHA] = UINT16_MAX;
+
+ weights[0] = 89;
+ weights[1] = 166;
+
+ cs->mixColors(pixelPtrs, weights, 2, reinterpret_cast<Q_UINT8 *>(outputPixel));
+
+ CHECK((uint)outputPixel[PIXEL_RED], UINT16_MAX);
+ CHECK((uint)outputPixel[PIXEL_GREEN], UINT16_MAX);
+ CHECK((uint)outputPixel[PIXEL_BLUE], UINT16_MAX);
+ CHECK_TOLERANCE((uint)outputPixel[PIXEL_ALPHA], (89u * 0u + 166u * UINT16_MAX) / 255u, 5u);
+}
+
+#define PIXELS_WIDTH 2
+#define PIXELS_HEIGHT 2
+
+void KisRgbU16ColorSpaceTester::testToQImage()
+{
+ KisProfile *defProfile = new KisProfile(cmsCreate_sRGBProfile());
+
+ KisAbstractColorSpace * cs = new KisRgbU16ColorSpace(defProfile);
+
+ KisRgbU16ColorSpace::Pixel pixels[PIXELS_WIDTH * PIXELS_HEIGHT] = {
+ {MAX_CHANNEL_VALUE, MAX_CHANNEL_VALUE, MAX_CHANNEL_VALUE, MAX_CHANNEL_VALUE / 4},
+ {MAX_CHANNEL_VALUE / 4, MAX_CHANNEL_VALUE / 2, MAX_CHANNEL_VALUE / 3, MAX_CHANNEL_VALUE / 2},
+ {MAX_CHANNEL_VALUE, MAX_CHANNEL_VALUE, MAX_CHANNEL_VALUE, MIN_CHANNEL_VALUE},
+ {MIN_CHANNEL_VALUE, MIN_CHANNEL_VALUE, MIN_CHANNEL_VALUE, MAX_CHANNEL_VALUE}
+ };
+
+ QImage image = cs->convertToQImage(reinterpret_cast<const Q_UINT8 *>(pixels), PIXELS_WIDTH, PIXELS_HEIGHT, 0, 0);
+
+ QRgb c = image.pixel(0, 0);
+
+ CHECK(qRed(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE));
+ CHECK(qGreen(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE));
+ CHECK(qBlue(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE));
+ CHECK(qAlpha(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE / 4));
+
+ c = image.pixel(1, 0);
+
+ CHECK(qRed(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE / 3));
+ CHECK(qGreen(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE / 2));
+ CHECK_TOLERANCE(qBlue(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE / 4), 1u);
+ CHECK(qAlpha(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE / 2));
+
+ c = image.pixel(0, 1);
+
+ CHECK(qRed(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE));
+ CHECK(qGreen(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE));
+ CHECK(qBlue(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE));
+ CHECK(qAlpha(c), (int)UINT16_TO_UINT8(MIN_CHANNEL_VALUE));
+
+ c = image.pixel(1, 1);
+
+ CHECK(qRed(c), (int)UINT16_TO_UINT8(MIN_CHANNEL_VALUE));
+ CHECK(qGreen(c), (int)UINT16_TO_UINT8(MIN_CHANNEL_VALUE));
+ CHECK(qBlue(c), (int)UINT16_TO_UINT8(MIN_CHANNEL_VALUE));
+ CHECK(qAlpha(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE));
+}
+
+#define NUM_ROWS 2
+#define NUM_COLUMNS 2
+#define SRC_ROW_STRIDE (NUM_COLUMNS * CHANNEL_SIZE)
+#define DST_ROW_STRIDE (NUM_COLUMNS * CHANNEL_SIZE)
+#define MASK_ROW_STRIDE NUM_COLUMNS
+
+/*
+1 alpha 1 0 alpha 1
+1 alpha 0.5 0 alpha 1
+1 alpha 0.5 0 alpha 0.5
+1 alpha 0 0 alpha 0.5
+
+*/
+
+void KisRgbU16ColorSpaceTester::testCompositeOps()
+{
+ KisProfile *defProfile = new KisProfile(cmsCreate_sRGBProfile());
+
+ KisRgbU16ColorSpace *cs = new KisRgbU16ColorSpace(defProfile);
+
+ KisRgbU16ColorSpace::Pixel srcPixel;
+ KisRgbU16ColorSpace::Pixel dstPixel;
+
+ srcPixel.red = UINT8_TO_UINT16(102);
+ srcPixel.green = UINT8_TO_UINT16(170);
+ srcPixel.blue = UINT8_TO_UINT16(238);
+ srcPixel.alpha = KisRgbU16ColorSpace::U16_OPACITY_OPAQUE;
+
+ dstPixel = srcPixel;
+
+ cs->compositeDivide(reinterpret_cast<Q_UINT8 *>(&dstPixel), 1, reinterpret_cast<const Q_UINT8 *>(&srcPixel),
+ 1, 0, 0, 1, 1, KisRgbU16ColorSpace::U16_OPACITY_OPAQUE);
+ /*
+ CHECK(dstPixel.red, (Q_UINT16)UINT8_TO_UINT16(253));
+ CHECK(dstPixel.green, (Q_UINT16)UINT8_TO_UINT16(254));
+ CHECK(dstPixel.blue, (Q_UINT16)UINT8_TO_UINT16(254));
+ CHECK(dstPixel.alpha, KisRgbU16ColorSpace::U16_OPACITY_OPAQUE);
+
+ Q_UINT16 srcColor = 43690;
+ Q_UINT16 dstColor = 43690;
+
+ srcColor = QMIN((dstColor * (65535u + 1u) + (srcColor / 2u)) / (1u + srcColor), 65535u);
+
+ CHECK((int)srcColor, 65534);
+
+ Q_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, 65535u);
+
+ CHECK((int)newColor, 65534);
+ */
+
+ /*
+ KisRgbU16ColorSpace::Pixel srcPixels[NUM_ROWS * NUM_COLUMNS] = {
+ {MAX_CHANNEL_VALUE, MAX_CHANNEL_VALUE, MAX_CHANNEL_VALUE, MAX_CHANNEL_VALUE / 4},
+ {MAX_CHANNEL_VALUE / 4, MAX_CHANNEL_VALUE / 2, MAX_CHANNEL_VALUE / 3, MAX_CHANNEL_VALUE / 2},
+ {MAX_CHANNEL_VALUE, MAX_CHANNEL_VALUE, MAX_CHANNEL_VALUE, MIN_CHANNEL_VALUE},
+ {MIN_CHANNEL_VALUE, MIN_CHANNEL_VALUE, MIN_CHANNEL_VALUE, MAX_CHANNEL_VALUE}
+ };
+
+ KisRgbU16ColorSpace::Pixel dstPixels[NUM_ROWS * NUM_COLUMNS] = {
+ {MAX_CHANNEL_VALUE, MAX_CHANNEL_VALUE, MAX_CHANNEL_VALUE, MAX_CHANNEL_VALUE / 4},
+ {MAX_CHANNEL_VALUE / 4, MAX_CHANNEL_VALUE / 2, MAX_CHANNEL_VALUE / 3, MAX_CHANNEL_VALUE / 2},
+ {MAX_CHANNEL_VALUE, MAX_CHANNEL_VALUE, MAX_CHANNEL_VALUE, MIN_CHANNEL_VALUE},
+ {MIN_CHANNEL_VALUE, MIN_CHANNEL_VALUE, MIN_CHANNEL_VALUE, MAX_CHANNEL_VALUE}
+ };
+
+ cs->compositeOver(reinterpret_cast<Q_UINT8 *>(dstPixels), DST_ROW_STRIDE, reinterpret_cast<const Q_UINT8 *>(srcPixels),
+ SRC_ROW_STRIDE, mask, MASK_ROW_STRIDE, NUM_ROWS, NUM_COLUMNS, opacity);
+ */
+
+ delete cs;
+}
+
diff --git a/krita/colorspaces/rgb_u16/tests/kis_strategy_colorspace_rgb_u16_tester.h b/krita/colorspaces/rgb_u16/tests/kis_strategy_colorspace_rgb_u16_tester.h
new file mode 100644
index 00000000..e80a7a43
--- /dev/null
+++ b/krita/colorspaces/rgb_u16/tests/kis_strategy_colorspace_rgb_u16_tester.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2005 Adrian Page <adrian@pagenet.plus.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_STRATEGY_COLORSPACE_RGB_U16_TESTER_H
+#define KIS_STRATEGY_COLORSPACE_RGB_U16_TESTER_H
+
+#include <kunittest/tester.h>
+
+#define CHECK_TOLERANCE( x, y, tolerance ) \
+if ((x) <= (y) + (tolerance) && (x) >= (y) - (tolerance)) \
+{ \
+ success(QString(__FILE__) + "[" + QString::number(__LINE__) + "]: passed " + #x); \
+} \
+else \
+{ \
+ failure(QString(__FILE__) + "[" + QString::number(__LINE__) + QString("]: failed ") + #x + "\n Expected " + #y + ", Actual result " + QString::number(x)); \
+} \
+
+class KisRgbU16ColorSpaceTester : public KUnitTest::Tester
+{
+public:
+ void allTests();
+ void testBasics();
+ void testMixColors();
+ void testToQImage();
+ void testCompositeOps();
+};
+
+#endif
+