diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-26 00:41:16 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-26 00:41:16 +0000 |
commit | 698569f8428ca088f764d704034a1330517b98c0 (patch) | |
tree | bf45be6946ebbbee9cce5a5bcf838f4c952d87e6 /chalk/colorspaces/rgb_u16 | |
parent | 2785103a6bd4de55bd26d79e34d0fdd4b329a73a (diff) | |
download | koffice-698569f8428ca088f764d704034a1330517b98c0.tar.gz koffice-698569f8428ca088f764d704034a1330517b98c0.zip |
Finish rebranding of Krita as Chalk
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238363 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'chalk/colorspaces/rgb_u16')
-rw-r--r-- | chalk/colorspaces/rgb_u16/Makefile.am | 32 | ||||
-rw-r--r-- | chalk/colorspaces/rgb_u16/chalk_rgb_u16_plugin.desktop | 80 | ||||
-rw-r--r-- | chalk/colorspaces/rgb_u16/kis_rgb_u16_colorspace.cc | 869 | ||||
-rw-r--r-- | chalk/colorspaces/rgb_u16/kis_rgb_u16_colorspace.h | 128 | ||||
-rw-r--r-- | chalk/colorspaces/rgb_u16/rgb_u16_plugin.cc | 61 | ||||
-rw-r--r-- | chalk/colorspaces/rgb_u16/rgb_u16_plugin.h | 37 | ||||
-rw-r--r-- | chalk/colorspaces/rgb_u16/tests/Makefile.am | 17 | ||||
-rw-r--r-- | chalk/colorspaces/rgb_u16/tests/kis_strategy_colorspace_rgb_u16_tester.cc | 524 | ||||
-rw-r--r-- | chalk/colorspaces/rgb_u16/tests/kis_strategy_colorspace_rgb_u16_tester.h | 46 |
9 files changed, 1794 insertions, 0 deletions
diff --git a/chalk/colorspaces/rgb_u16/Makefile.am b/chalk/colorspaces/rgb_u16/Makefile.am new file mode 100644 index 00000000..28ef3e62 --- /dev/null +++ b/chalk/colorspaces/rgb_u16/Makefile.am @@ -0,0 +1,32 @@ +# location for the rc file +kde_services_DATA = chalk_rgb_u16_plugin.desktop + +INCLUDES = -I$(srcdir)/../../sdk \ + -I$(srcdir)/../../chalkcolor/color_strategy/ \ + -I$(srcdir)/../../chalkcolor \ + $(KOFFICE_INCLUDES) \ + $(all_includes) + +lib_LTLIBRARIES = libchalk_rgb_u16.la +libchalk_rgb_u16_la_SOURCES = kis_rgb_u16_colorspace.cc +libchalk_rgb_u16_la_LDFLAGS = $(all_libraries) +libchalk_rgb_u16_la_LIBADD = ../../chalkcolor/libchalkcolor.la + +# Install this plugin in the KDE modules directory +kde_module_LTLIBRARIES = chalk_rgb_u16_plugin.la + +# Srcs for the plugin +chalk_rgb_u16_plugin_la_SOURCES = rgb_u16_plugin.cc +noinst_HEADERS = rgb_u16_plugin.h kis_rgb_u16_colorspace.h + +chalk_rgb_u16_plugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_QT) -lkdecore -lkdeui -lkjs -lkdefx -lkio -lkparts -llcms +chalk_rgb_u16_plugin_la_LIBADD = libchalk_rgb_u16.la ../../chalkcolor/libchalkcolor.la + +chalk_rgb_u16_plugin_la_METASOURCES = AUTO + +if include_kunittest_tests +TESTSDIR = tests +endif + +SUBDIRS = . $(TESTSDIR) + diff --git a/chalk/colorspaces/rgb_u16/chalk_rgb_u16_plugin.desktop b/chalk/colorspaces/rgb_u16/chalk_rgb_u16_plugin.desktop new file mode 100644 index 00000000..36ff2355 --- /dev/null +++ b/chalk/colorspaces/rgb_u16/chalk_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=Chalk/ColorSpace +Type=Service +X-KDE-Library=chalk_rgb_u16_plugin +X-Chalk-Version=2 + diff --git a/chalk/colorspaces/rgb_u16/kis_rgb_u16_colorspace.cc b/chalk/colorspaces/rgb_u16/kis_rgb_u16_colorspace.cc new file mode 100644 index 00000000..c61433d2 --- /dev/null +++ b/chalk/colorspaces/rgb_u16/kis_rgb_u16_colorspace.cc @@ -0,0 +1,869 @@ +/* + * Copyright (c) 2002 Patrick Julien <[email protected]> + * Copyright (c) 2004 Boudewijn Rempt <[email protected]> + * Copyright (c) 2005 Adrian Page <[email protected]> + * + * 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 <tqimage.h> +#include <tqcolor.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 TQ_INT32 MAX_CHANNEL_RGB = 3; + const TQ_INT32 MAX_CHANNEL_RGBA = 4; +} + +// XXX: already defined is superclass? +//const TQ_UINT16 KisRgbU16ColorSpace::U16_OPACITY_OPAQUE; +//const TQ_UINT16 KisRgbU16ColorSpace::U16_OPACITY_TRANSPARENT; + +KisRgbU16ColorSpace::KisRgbU16ColorSpace(KisColorSpaceFactoryRegistry * tqparent, KisProfile *p) : + KisU16BaseColorSpace(KisID("RGBA16", i18n("RGB (16-bit integer/channel)")), TYPE_BGRA_16, icSigRgbData, tqparent, p) +{ + m_channels.push_back(new KisChannelInfo(i18n("Red"), i18n("R"), PIXEL_RED * sizeof(TQ_UINT16), KisChannelInfo::COLOR, KisChannelInfo::UINT16, sizeof(TQ_UINT16), TQColor(255,0,0))); + m_channels.push_back(new KisChannelInfo(i18n("Green"), i18n("G"), PIXEL_GREEN * sizeof(TQ_UINT16), KisChannelInfo::COLOR, KisChannelInfo::UINT16, sizeof(TQ_UINT16), TQColor(0,255,0))); + m_channels.push_back(new KisChannelInfo(i18n("Blue"), i18n("B"), PIXEL_BLUE * sizeof(TQ_UINT16), KisChannelInfo::COLOR, KisChannelInfo::UINT16, sizeof(TQ_UINT16), TQColor(0,0,255))); + m_channels.push_back(new KisChannelInfo(i18n("Alpha"), i18n("A"), PIXEL_ALPHA * sizeof(TQ_UINT16), KisChannelInfo::ALPHA, KisChannelInfo::UINT16, sizeof(TQ_UINT16))); + + m_alphaPos = PIXEL_ALPHA * sizeof(TQ_UINT16); + + init(); +} + +KisRgbU16ColorSpace::~KisRgbU16ColorSpace() +{ +} + +void KisRgbU16ColorSpace::setPixel(TQ_UINT8 *dst, TQ_UINT16 red, TQ_UINT16 green, TQ_UINT16 blue, TQ_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 TQ_UINT8 *src, TQ_UINT16 *red, TQ_UINT16 *green, TQ_UINT16 *blue, TQ_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 TQ_UINT8 **colors, const TQ_UINT8 *weights, TQ_UINT32 nColors, TQ_UINT8 *dst) const +{ + TQ_UINT32 totalRed = 0, totalGreen = 0, totalBlue = 0, newAlpha = 0; + + while (nColors--) + { + const Pixel *pixel = reinterpret_cast<const Pixel *>(*colors); + + TQ_UINT32 alpha = pixel->alpha; + TQ_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(TQ_UINT8** colors, TQ_INT32* kernelValues, KisChannelInfo::enumChannelFlags channelFlags, TQ_UINT8 *dst, + TQ_INT32 factor, TQ_INT32 offset, TQ_INT32 nColors) const +{ + TQ_INT32 totalRed = 0, totalGreen = 0, totalBlue = 0, totalAlpha = 0; + + while (nColors--) + { + const Pixel * pixel = reinterpret_cast<const Pixel *>( *colors ); + + TQ_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, TQ_UINT16_MAX); + p->green = CLAMP( ( totalGreen / factor) + offset, 0, TQ_UINT16_MAX); + p->blue = CLAMP( ( totalBlue / factor) + offset, 0, TQ_UINT16_MAX); + } + if (channelFlags & KisChannelInfo::FLAG_ALPHA) { + p->alpha = CLAMP((totalAlpha/ factor) + offset, 0, TQ_UINT16_MAX); + } +} + + +void KisRgbU16ColorSpace::invertColor(TQ_UINT8 * src, TQ_INT32 nPixels) +{ + TQ_UINT32 psize = pixelSize(); + + while (nPixels--) + { + Pixel * p = reinterpret_cast< Pixel *>( src ); + p->red = TQ_UINT16_MAX - p->red; + p->green = TQ_UINT16_MAX - p->green; + p->blue = TQ_UINT16_MAX - p->blue; + src += psize; + } +} + +TQ_UINT8 KisRgbU16ColorSpace::intensity8(const TQ_UINT8 * src) const +{ + const Pixel * p = reinterpret_cast<const Pixel *>( src ); + + return UINT16_TO_UINT8(static_cast<TQ_UINT16>((p->red * 0.30 + p->green * 0.59 + p->blue * 0.11) + 0.5)); +} + + +TQValueVector<KisChannelInfo *> KisRgbU16ColorSpace::channels() const +{ + return m_channels; +} + +TQ_UINT32 KisRgbU16ColorSpace::nChannels() const +{ + return MAX_CHANNEL_RGBA; +} + +TQ_UINT32 KisRgbU16ColorSpace::nColorChannels() const +{ + return MAX_CHANNEL_RGB; +} + +TQ_UINT32 KisRgbU16ColorSpace::pixelSize() const +{ + return MAX_CHANNEL_RGBA * sizeof(TQ_UINT16); +} + + +void KisRgbU16ColorSpace::compositeOver(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmaskRowStart, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT16 opacity) +{ + while (rows > 0) { + + const TQ_UINT16 *src = reinterpret_cast<const TQ_UINT16 *>(srcRowStart); + TQ_UINT16 *dst = reinterpret_cast<TQ_UINT16 *>(dstRowStart); + const TQ_UINT8 *tqmask = tqmaskRowStart; + TQ_INT32 columns = numColumns; + + while (columns > 0) { + + TQ_UINT16 srcAlpha = src[PIXEL_ALPHA]; + + // apply the alphatqmask + if (tqmask != 0) { + TQ_UINT8 U8_tqmask = *tqmask; + + if (U8_tqmask != OPACITY_OPAQUE) { + srcAlpha = UINT16_MULT(srcAlpha, UINT8_TO_UINT16(U8_tqmask)); + } + tqmask++; + } + + 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(TQ_UINT16)); + } else { + TQ_UINT16 dstAlpha = dst[PIXEL_ALPHA]; + + TQ_UINT16 srcBlend; + + if (dstAlpha == U16_OPACITY_OPAQUE) { + srcBlend = srcAlpha; + } else { + TQ_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(TQ_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(tqmaskRowStart) { + tqmaskRowStart += tqmaskRowStride; + } + } +} + +#define COMMON_COMPOSITE_OP_PROLOG() \ + while (rows > 0) { \ + \ + const TQ_UINT16 *src = reinterpret_cast<const TQ_UINT16 *>(srcRowStart); \ + TQ_UINT16 *dst = reinterpret_cast<TQ_UINT16 *>(dstRowStart); \ + TQ_INT32 columns = numColumns; \ + const TQ_UINT8 *tqmask = tqmaskRowStart; \ + \ + while (columns > 0) { \ + \ + TQ_UINT16 srcAlpha = src[PIXEL_ALPHA]; \ + TQ_UINT16 dstAlpha = dst[PIXEL_ALPHA]; \ + \ + srcAlpha = TQMIN(srcAlpha, dstAlpha); \ + \ + if (tqmask != 0) { \ + TQ_UINT8 U8_tqmask = *tqmask; \ + \ + if (U8_tqmask != OPACITY_OPAQUE) { \ + srcAlpha = UINT16_MULT(srcAlpha, UINT8_TO_UINT16(U8_tqmask)); \ + } \ + tqmask++; \ + } \ + \ + if (srcAlpha != U16_OPACITY_TRANSPARENT) { \ + \ + if (opacity != U16_OPACITY_OPAQUE) { \ + srcAlpha = UINT16_MULT(srcAlpha, opacity); \ + } \ + \ + TQ_UINT16 srcBlend; \ + \ + if (dstAlpha == U16_OPACITY_OPAQUE) { \ + srcBlend = srcAlpha; \ + } else { \ + TQ_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(tqmaskRowStart) { \ + tqmaskRowStart += tqmaskRowStride; \ + } \ + } + +void KisRgbU16ColorSpace::compositeMultiply(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmaskRowStart, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT16 opacity) +{ + COMMON_COMPOSITE_OP_PROLOG(); + + { + + for (int channel = 0; channel < MAX_CHANNEL_RGB; channel++) { + TQ_UINT16 srcColor = src[channel]; + TQ_UINT16 dstColor = dst[channel]; + + srcColor = UINT16_MULT(srcColor, dstColor); + + dst[channel] = UINT16_BLEND(srcColor, dstColor, srcBlend); + + } + } + + COMMON_COMPOSITE_OP_EPILOG(); +} + +void KisRgbU16ColorSpace::compositeDivide(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmaskRowStart, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT16 opacity) +{ + COMMON_COMPOSITE_OP_PROLOG(); + + { + for (int channel = 0; channel < MAX_CHANNEL_RGB; channel++) { + + TQ_UINT16 srcColor = src[channel]; + TQ_UINT16 dstColor = dst[channel]; + + srcColor = TQMIN((dstColor * (UINT16_MAX + 1u) + (srcColor / 2u)) / (1u + srcColor), UINT16_MAX); + + TQ_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend); + + dst[channel] = newColor; + } + } + + COMMON_COMPOSITE_OP_EPILOG(); +} + +void KisRgbU16ColorSpace::compositeScreen(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmaskRowStart, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT16 opacity) +{ + COMMON_COMPOSITE_OP_PROLOG(); + + { + for (int channel = 0; channel < MAX_CHANNEL_RGB; channel++) { + + TQ_UINT16 srcColor = src[channel]; + TQ_UINT16 dstColor = dst[channel]; + + srcColor = UINT16_MAX - UINT16_MULT(UINT16_MAX - dstColor, UINT16_MAX - srcColor); + + TQ_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend); + + dst[channel] = newColor; + } + } + + COMMON_COMPOSITE_OP_EPILOG(); +} + +void KisRgbU16ColorSpace::compositeOverlay(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmaskRowStart, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT16 opacity) +{ + COMMON_COMPOSITE_OP_PROLOG(); + + { + for (int channel = 0; channel < MAX_CHANNEL_RGB; channel++) { + + TQ_UINT16 srcColor = src[channel]; + TQ_UINT16 dstColor = dst[channel]; + + srcColor = UINT16_MULT(dstColor, dstColor + 2u * UINT16_MULT(srcColor, UINT16_MAX - dstColor)); + + TQ_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend); + + dst[channel] = newColor; + } + } + + COMMON_COMPOSITE_OP_EPILOG(); +} + +void KisRgbU16ColorSpace::compositeDodge(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmaskRowStart, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT16 opacity) +{ + COMMON_COMPOSITE_OP_PROLOG(); + + { + for (int channel = 0; channel < MAX_CHANNEL_RGB; channel++) { + + TQ_UINT16 srcColor = src[channel]; + TQ_UINT16 dstColor = dst[channel]; + + srcColor = TQMIN((dstColor * (UINT16_MAX + 1u)) / (UINT16_MAX + 1u - srcColor), UINT16_MAX); + + TQ_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend); + + dst[channel] = newColor; + } + } + + COMMON_COMPOSITE_OP_EPILOG(); +} + +void KisRgbU16ColorSpace::compositeBurn(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmaskRowStart, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT16 opacity) +{ + COMMON_COMPOSITE_OP_PROLOG(); + + { + for (int channel = 0; channel < MAX_CHANNEL_RGB; channel++) { + + TQ_UINT16 srcColor = src[channel]; + TQ_UINT16 dstColor = dst[channel]; + + srcColor = kMin(((UINT16_MAX - dstColor) * (UINT16_MAX + 1u)) / (srcColor + 1u), UINT16_MAX); + srcColor = kClamp(UINT16_MAX - srcColor, 0u, UINT16_MAX); + + TQ_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend); + + dst[channel] = newColor; + } + } + + COMMON_COMPOSITE_OP_EPILOG(); +} + +void KisRgbU16ColorSpace::compositeDarken(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmaskRowStart, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT16 opacity) +{ + COMMON_COMPOSITE_OP_PROLOG(); + + { + for (int channel = 0; channel < MAX_CHANNEL_RGB; channel++) { + + TQ_UINT16 srcColor = src[channel]; + TQ_UINT16 dstColor = dst[channel]; + + srcColor = TQMIN(srcColor, dstColor); + + TQ_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend); + + dst[channel] = newColor; + } + } + + COMMON_COMPOSITE_OP_EPILOG(); +} + +void KisRgbU16ColorSpace::compositeLighten(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmaskRowStart, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT16 opacity) +{ + COMMON_COMPOSITE_OP_PROLOG(); + + { + for (int channel = 0; channel < MAX_CHANNEL_RGB; channel++) { + + TQ_UINT16 srcColor = src[channel]; + TQ_UINT16 dstColor = dst[channel]; + + srcColor = TQMAX(srcColor, dstColor); + + TQ_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend); + + dst[channel] = newColor; + } + } + + COMMON_COMPOSITE_OP_EPILOG(); +} + +void KisRgbU16ColorSpace::compositeHue(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmaskRowStart, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_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; + + TQ_UINT16 dstRed = dst[PIXEL_RED]; + TQ_UINT16 dstGreen = dst[PIXEL_GREEN]; + TQ_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); + + TQ_UINT16 srcRed = static_cast<TQ_UINT16>(FSrcRed * UINT16_MAX + 0.5); + TQ_UINT16 srcGreen = static_cast<TQ_UINT16>(FSrcGreen * UINT16_MAX + 0.5); + TQ_UINT16 srcBlue = static_cast<TQ_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(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmaskRowStart, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_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; + + TQ_UINT16 dstRed = dst[PIXEL_RED]; + TQ_UINT16 dstGreen = dst[PIXEL_GREEN]; + TQ_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); + + TQ_UINT16 srcRed = static_cast<TQ_UINT16>(FSrcRed * UINT16_MAX + 0.5); + TQ_UINT16 srcGreen = static_cast<TQ_UINT16>(FSrcGreen * UINT16_MAX + 0.5); + TQ_UINT16 srcBlue = static_cast<TQ_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(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmaskRowStart, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_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; + + TQ_UINT16 dstRed = dst[PIXEL_RED]; + TQ_UINT16 dstGreen = dst[PIXEL_GREEN]; + TQ_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); + + TQ_UINT16 srcRed = static_cast<TQ_UINT16>(FSrcRed * UINT16_MAX + 0.5); + TQ_UINT16 srcGreen = static_cast<TQ_UINT16>(FSrcGreen * UINT16_MAX + 0.5); + TQ_UINT16 srcBlue = static_cast<TQ_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(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmaskRowStart, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_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; + + TQ_UINT16 dstRed = dst[PIXEL_RED]; + TQ_UINT16 dstGreen = dst[PIXEL_GREEN]; + TQ_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); + + TQ_UINT16 srcRed = static_cast<TQ_UINT16>(FSrcRed * UINT16_MAX + 0.5); + TQ_UINT16 srcGreen = static_cast<TQ_UINT16>(FSrcGreen * UINT16_MAX + 0.5); + TQ_UINT16 srcBlue = static_cast<TQ_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(TQ_UINT8 *dst, + TQ_INT32 dstRowSize, + const TQ_UINT8 *src, + TQ_INT32 srcRowSize, + const TQ_UINT8 *srcAlphaMask, + TQ_INT32 tqmaskRowStride, + TQ_INT32 rows, + TQ_INT32 cols, + TQ_UINT16 /*opacity*/) +{ + while (rows-- > 0) + { + const Pixel *s = reinterpret_cast<const Pixel *>(src); + Pixel *d = reinterpret_cast<Pixel *>(dst); + const TQ_UINT8 *tqmask = srcAlphaMask; + + for (TQ_INT32 i = cols; i > 0; i--, s++, d++) + { + TQ_UINT16 srcAlpha = s->alpha; + + // apply the alphatqmask + if (tqmask != 0) { + TQ_UINT8 U8_tqmask = *tqmask; + + if (U8_tqmask != OPACITY_OPAQUE) { + srcAlpha = UINT16_BLEND(srcAlpha, U16_OPACITY_OPAQUE, UINT8_TO_UINT16(U8_tqmask)); + } + tqmask++; + } + d->alpha = UINT16_MULT(srcAlpha, d->alpha); + } + + dst += dstRowSize; + src += srcRowSize; + if(srcAlphaMask) { + srcAlphaMask += tqmaskRowStride; + } + } +} + +void KisRgbU16ColorSpace::bitBlt(TQ_UINT8 *dst, + TQ_INT32 dstRowStride, + const TQ_UINT8 *src, + TQ_INT32 srcRowStride, + const TQ_UINT8 *tqmask, + TQ_INT32 tqmaskRowStride, + TQ_UINT8 U8_opacity, + TQ_INT32 rows, + TQ_INT32 cols, + const KisCompositeOp& op) +{ + TQ_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, tqmask, tqmaskRowStride, 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, tqmask, tqmaskRowStride, rows, cols, opacity); + break; + case COMPOSITE_DIVIDE: + compositeDivide(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, 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, tqmask, tqmaskRowStride, 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, tqmask, tqmaskRowStride, rows, cols, opacity); + break; + case COMPOSITE_LIGHTEN: + compositeLighten(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity); + break; + case COMPOSITE_HUE: + compositeHue(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity); + break; + case COMPOSITE_SATURATION: + compositeSaturation(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity); + break; + case COMPOSITE_VALUE: + compositeValue(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity); + break; + case COMPOSITE_COLOR: + compositeColor(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, 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, tqmask, tqmaskRowStride, rows, cols, opacity); + break; + case COMPOSITE_OVERLAY: + compositeOverlay(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity); + break; + case COMPOSITE_ERASE: + compositeErase(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity); + break; + case COMPOSITE_DODGE: + compositeDodge(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity); + break; + case COMPOSITE_BURN: + compositeBurn(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity); + break; + case COMPOSITE_ALPHA_DARKEN: + abstractCompositeAlphaDarken<TQ_UINT16, U16Mult, Uint8ToU16, U16OpacityTest, + PIXEL_ALPHA, MAX_CHANNEL_RGB, MAX_CHANNEL_RGBA>( + dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, + 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/chalk/colorspaces/rgb_u16/kis_rgb_u16_colorspace.h b/chalk/colorspaces/rgb_u16/kis_rgb_u16_colorspace.h new file mode 100644 index 00000000..a4edbffa --- /dev/null +++ b/chalk/colorspaces/rgb_u16/kis_rgb_u16_colorspace.h @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2002 Patrick Julien <[email protected]> + * Copyright (c) 2005 Adrian Page <[email protected]> + * + * 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 { + TQ_UINT16 blue; + TQ_UINT16 green; + TQ_UINT16 red; + TQ_UINT16 alpha; + }; +public: + KisRgbU16ColorSpace(KisColorSpaceFactoryRegistry * tqparent, KisProfile *p); + virtual ~KisRgbU16ColorSpace(); + + virtual bool willDegrade(ColorSpaceIndependence independence) + { + if (independence == TO_RGBA8) + return true; + else + return false; + }; + + + +public: + void setPixel(TQ_UINT8 *pixel, TQ_UINT16 red, TQ_UINT16 green, TQ_UINT16 blue, TQ_UINT16 alpha) const; + void getPixel(const TQ_UINT8 *pixel, TQ_UINT16 *red, TQ_UINT16 *green, TQ_UINT16 *blue, TQ_UINT16 *alpha) const; + + virtual void mixColors(const TQ_UINT8 **colors, const TQ_UINT8 *weights, TQ_UINT32 nColors, TQ_UINT8 *dst) const; + virtual void convolveColors(TQ_UINT8** colors, TQ_INT32* kernelValues, KisChannelInfo::enumChannelFlags channelFlags, TQ_UINT8 *dst, TQ_INT32 factor, TQ_INT32 offset, TQ_INT32 nColors) const; + virtual void invertColor(TQ_UINT8 * src, TQ_INT32 nPixels); + virtual TQ_UINT8 intensity8(const TQ_UINT8 * src) const; + + virtual TQValueVector<KisChannelInfo *> channels() const; + virtual TQ_UINT32 nChannels() const; + virtual TQ_UINT32 nColorChannels() const; + virtual TQ_UINT32 pixelSize() const; + + virtual KisCompositeOpList userVisiblecompositeOps() const; + +protected: + + virtual void bitBlt(TQ_UINT8 *dst, + TQ_INT32 dstRowStride, + const TQ_UINT8 *src, + TQ_INT32 srcRowStride, + const TQ_UINT8 *srcAlphaMask, + TQ_INT32 tqmaskRowStride, + TQ_UINT8 opacity, + TQ_INT32 rows, + TQ_INT32 cols, + const KisCompositeOp& op); + + void compositeOver(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity); + void compositeMultiply(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity); + void compositeDivide(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity); + void compositeScreen(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity); + void compositeOverlay(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity); + void compositeDodge(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity); + void compositeBurn(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity); + void compositeDarken(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity); + void compositeLighten(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity); + void compositeHue(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity); + void compositeSaturation(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity); + void compositeValue(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity); + void compositeColor(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity); + void compositeErase(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity); + +private: + friend class KisRgbU16ColorSpaceTester; + + static const TQ_UINT8 PIXEL_BLUE = 0; + static const TQ_UINT8 PIXEL_GREEN = 1; + static const TQ_UINT8 PIXEL_RED = 2; + static const TQ_UINT8 PIXEL_ALPHA = 3; +}; + +class KisRgbU16ColorSpaceFactory : public KisColorSpaceFactory +{ +public: + /** + * Chalk 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 TQ_UINT32 colorSpaceType() { return TYPE_BGRA_16; }; + + virtual icColorSpaceSignature colorSpaceSignature() { return icSigRgbData; }; + + virtual KisColorSpace *createColorSpace(KisColorSpaceFactoryRegistry * tqparent, KisProfile *p) { return new KisRgbU16ColorSpace(tqparent, p); }; + + virtual TQString defaultProfile() { return "sRGB built-in - (lcms internal)"; }; +}; + +#endif // KIS_STRATEGY_COLORSPACE_RGB_U16_H_ diff --git a/chalk/colorspaces/rgb_u16/rgb_u16_plugin.cc b/chalk/colorspaces/rgb_u16/rgb_u16_plugin.cc new file mode 100644 index 00000000..828298c3 --- /dev/null +++ b/chalk/colorspaces/rgb_u16/rgb_u16_plugin.cc @@ -0,0 +1,61 @@ +/* +* rgb_u16_plugin.cc -- Part of Chalk +* +* Copyright (c) 2004 Boudewijn Rempt ([email protected]) +* Copyright (c) 2005 Adrian Page <[email protected]> +* +* 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( chalk_rgb_u16_plugin, RGBU16PluginFactory( "chalk" ) ) + + +RGBU16Plugin::RGBU16Plugin(TQObject *tqparent, const char *name, const TQStringList &) + : KParts::Plugin(tqparent, name) +{ + setInstance(RGBU16PluginFactory::instance()); + + if ( tqparent->inherits("KisColorSpaceFactoryRegistry") ) + { + KisColorSpaceFactoryRegistry * f = dynamic_cast<KisColorSpaceFactoryRegistry *>( tqparent ); + + 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/chalk/colorspaces/rgb_u16/rgb_u16_plugin.h b/chalk/colorspaces/rgb_u16/rgb_u16_plugin.h new file mode 100644 index 00000000..d5cf4d14 --- /dev/null +++ b/chalk/colorspaces/rgb_u16/rgb_u16_plugin.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2003 Boudewijn Rempt ([email protected]) + * + * 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 + TQ_OBJECT +public: + RGBU16Plugin(TQObject *tqparent, const char *name, const TQStringList &); + virtual ~RGBU16Plugin(); +}; + + +#endif // RGB_U16_PLUGIN_H_ diff --git a/chalk/colorspaces/rgb_u16/tests/Makefile.am b/chalk/colorspaces/rgb_u16/tests/Makefile.am new file mode 100644 index 00000000..dcf23893 --- /dev/null +++ b/chalk/colorspaces/rgb_u16/tests/Makefile.am @@ -0,0 +1,17 @@ +AM_CPPFLAGS = -I$(srcdir)/.. \ + -I$(srcdir)/../../../sdk \ + -I$(srcdir)/../../../chalkcolor/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 ../libchalk_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/chalk/colorspaces/rgb_u16/tests/kis_strategy_colorspace_rgb_u16_tester.cc b/chalk/colorspaces/rgb_u16/tests/kis_strategy_colorspace_rgb_u16_tester.cc new file mode 100644 index 00000000..7861b8e1 --- /dev/null +++ b/chalk/colorspaces/rgb_u16/tests/kis_strategy_colorspace_rgb_u16_tester.cc @@ -0,0 +1,524 @@ +/* + * Copyright (c) 2005 Adrian Page <[email protected]> + * + * 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(); + testToTQImage(); + 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); + + TQValueVector<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); + + TQ_UINT16 pixel[NUM_CHANNELS]; + + cs->fromTQColor(tqRgb(255, 255, 255), reinterpret_cast<TQ_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->fromTQColor(tqRgb(0, 0, 0), reinterpret_cast<TQ_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->fromTQColor(tqRgb(128, 64, 192), reinterpret_cast<TQ_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->fromTQColor(tqRgb(255, 255, 255), OPACITY_OPAQUE, reinterpret_cast<TQ_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->fromTQColor(tqRgb(255, 255, 255), OPACITY_TRANSPARENT, reinterpret_cast<TQ_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->fromTQColor(tqRgb(255, 255, 255), OPACITY_OPAQUE / 2, reinterpret_cast<TQ_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; + + TQColor c; + + cs->toTQColor(reinterpret_cast<const TQ_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->toTQColor(reinterpret_cast<const TQ_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->toTQColor(reinterpret_cast<const TQ_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; + + TQ_UINT8 opacity; + + cs->toTQColor(reinterpret_cast<const TQ_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->toTQColor(reinterpret_cast<const TQ_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->toTQColor(reinterpret_cast<const TQ_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->toTQColor(reinterpret_cast<const TQ_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<TQ_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; + + TQString valueText = cs->channelValueText(reinterpret_cast<TQ_UINT8 *>(pixel), RED_CHANNEL); + CHECK(valueText, TQString().setNum(MAX_CHANNEL_VALUE)); + + valueText = cs->channelValueText(reinterpret_cast<TQ_UINT8 *>(pixel), GREEN_CHANNEL); + CHECK(valueText, TQString().setNum(MAX_CHANNEL_VALUE / 2)); + + valueText = cs->channelValueText(reinterpret_cast<TQ_UINT8 *>(pixel), BLUE_CHANNEL); + CHECK(valueText, TQString().setNum(MAX_CHANNEL_VALUE / 4)); + + valueText = cs->channelValueText(reinterpret_cast<TQ_UINT8 *>(pixel), ALPHA_CHANNEL); + CHECK(valueText, TQString().setNum(MIN_CHANNEL_VALUE)); + + valueText = cs->normalisedChannelValueText(reinterpret_cast<TQ_UINT8 *>(pixel), RED_CHANNEL); + CHECK(valueText, TQString().setNum(static_cast<float>(MAX_CHANNEL_VALUE) / MAX_CHANNEL_VALUE)); + + valueText = cs->normalisedChannelValueText(reinterpret_cast<TQ_UINT8 *>(pixel), GREEN_CHANNEL); + CHECK(valueText, TQString().setNum(static_cast<float>(MAX_CHANNEL_VALUE / 2) / MAX_CHANNEL_VALUE)); + + valueText = cs->normalisedChannelValueText(reinterpret_cast<TQ_UINT8 *>(pixel), BLUE_CHANNEL); + CHECK(valueText, TQString().setNum(static_cast<float>(MAX_CHANNEL_VALUE / 4) / MAX_CHANNEL_VALUE)); + + valueText = cs->normalisedChannelValueText(reinterpret_cast<TQ_UINT8 *>(pixel), ALPHA_CHANNEL); + CHECK(valueText, TQString().setNum(static_cast<float>(MIN_CHANNEL_VALUE) / MAX_CHANNEL_VALUE)); + + cs->setPixel(reinterpret_cast<TQ_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); + + TQ_UINT16 red; + TQ_UINT16 green; + TQ_UINT16 blue; + TQ_UINT16 alpha; + + cs->getPixel(reinterpret_cast<const TQ_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. + TQ_UINT16 pixel1[NUM_CHANNELS]; + TQ_UINT16 pixel2[NUM_CHANNELS]; + TQ_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 TQ_UINT8 *pixelPtrs[2]; + TQ_UINT8 weights[2]; + + pixelPtrs[0] = reinterpret_cast<const TQ_UINT8 *>(pixel1); + pixelPtrs[1] = reinterpret_cast<const TQ_UINT8 *>(pixel2); + + weights[0] = 255; + weights[1] = 0; + + cs->mixColors(pixelPtrs, weights, 2, reinterpret_cast<TQ_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<TQ_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<TQ_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<TQ_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<TQ_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::testToTQImage() +{ + 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} + }; + + TQImage image = cs->convertToTQImage(reinterpret_cast<const TQ_UINT8 *>(pixels), PIXELS_WIDTH, PIXELS_HEIGHT, 0, 0); + + TQRgb c = image.pixel(0, 0); + + CHECK(tqRed(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE)); + CHECK(tqGreen(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE)); + CHECK(tqBlue(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE)); + CHECK(tqAlpha(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE / 4)); + + c = image.pixel(1, 0); + + CHECK(tqRed(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE / 3)); + CHECK(tqGreen(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE / 2)); + CHECK_TOLERANCE(tqBlue(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE / 4), 1u); + CHECK(tqAlpha(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE / 2)); + + c = image.pixel(0, 1); + + CHECK(tqRed(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE)); + CHECK(tqGreen(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE)); + CHECK(tqBlue(c), (int)UINT16_TO_UINT8(MAX_CHANNEL_VALUE)); + CHECK(tqAlpha(c), (int)UINT16_TO_UINT8(MIN_CHANNEL_VALUE)); + + c = image.pixel(1, 1); + + CHECK(tqRed(c), (int)UINT16_TO_UINT8(MIN_CHANNEL_VALUE)); + CHECK(tqGreen(c), (int)UINT16_TO_UINT8(MIN_CHANNEL_VALUE)); + CHECK(tqBlue(c), (int)UINT16_TO_UINT8(MIN_CHANNEL_VALUE)); + CHECK(tqAlpha(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<TQ_UINT8 *>(&dstPixel), 1, reinterpret_cast<const TQ_UINT8 *>(&srcPixel), + 1, 0, 0, 1, 1, KisRgbU16ColorSpace::U16_OPACITY_OPAQUE); + /* + CHECK(dstPixel.red, (TQ_UINT16)UINT8_TO_UINT16(253)); + CHECK(dstPixel.green, (TQ_UINT16)UINT8_TO_UINT16(254)); + CHECK(dstPixel.blue, (TQ_UINT16)UINT8_TO_UINT16(254)); + CHECK(dstPixel.alpha, KisRgbU16ColorSpace::U16_OPACITY_OPAQUE); + + TQ_UINT16 srcColor = 43690; + TQ_UINT16 dstColor = 43690; + + srcColor = TQMIN((dstColor * (65535u + 1u) + (srcColor / 2u)) / (1u + srcColor), 65535u); + + CHECK((int)srcColor, 65534); + + TQ_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<TQ_UINT8 *>(dstPixels), DST_ROW_STRIDE, reinterpret_cast<const TQ_UINT8 *>(srcPixels), + SRC_ROW_STRIDE, tqmask, MASK_ROW_STRIDE, NUM_ROWS, NUM_COLUMNS, opacity); + */ + + delete cs; +} + diff --git a/chalk/colorspaces/rgb_u16/tests/kis_strategy_colorspace_rgb_u16_tester.h b/chalk/colorspaces/rgb_u16/tests/kis_strategy_colorspace_rgb_u16_tester.h new file mode 100644 index 00000000..848cf1ac --- /dev/null +++ b/chalk/colorspaces/rgb_u16/tests/kis_strategy_colorspace_rgb_u16_tester.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2005 Adrian Page <[email protected]> + * + * 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(TQString(__FILE__) + "[" + TQString::number(__LINE__) + "]: passed " + #x); \ +} \ +else \ +{ \ + failure(TQString(__FILE__) + "[" + TQString::number(__LINE__) + TQString("]: failed ") + #x + "\n Expected " + #y + ", Actual result " + TQString::number(x)); \ +} \ + +class KisRgbU16ColorSpaceTester : public KUnitTest::Tester +{ +public: + void allTests(); + void testBasics(); + void testMixColors(); + void testToTQImage(); + void testCompositeOps(); +}; + +#endif + |