From 8b78a8791bc539bcffe7159f9d9714d577cb3d7d Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 23 May 2021 20:48:35 +0900 Subject: Renaming of files in preparation for code style tools. Signed-off-by: Michele Calgaro --- chalk/colorspaces/wetsticky/Makefile.am | 2 +- chalk/colorspaces/wetsticky/brushop/Makefile.am | 4 +- .../colorspaces/wetsticky/brushop/kis_wsbrushop.cc | 117 ---- .../wetsticky/brushop/kis_wsbrushop.cpp | 117 ++++ .../wetsticky/brushop/wsbrushpaintop_plugin.cc | 56 -- .../wetsticky/brushop/wsbrushpaintop_plugin.cpp | 56 ++ .../wetsticky/kis_wet_sticky_colorspace.cc | 605 --------------------- .../wetsticky/kis_wet_sticky_colorspace.cpp | 605 +++++++++++++++++++++ .../colorspaces/wetsticky/kis_ws_engine_filter.cc | 180 ------ .../colorspaces/wetsticky/kis_ws_engine_filter.cpp | 180 ++++++ chalk/colorspaces/wetsticky/wet_sticky_plugin.cc | 60 -- chalk/colorspaces/wetsticky/wet_sticky_plugin.cpp | 60 ++ 12 files changed, 1021 insertions(+), 1021 deletions(-) delete mode 100644 chalk/colorspaces/wetsticky/brushop/kis_wsbrushop.cc create mode 100644 chalk/colorspaces/wetsticky/brushop/kis_wsbrushop.cpp delete mode 100644 chalk/colorspaces/wetsticky/brushop/wsbrushpaintop_plugin.cc create mode 100644 chalk/colorspaces/wetsticky/brushop/wsbrushpaintop_plugin.cpp delete mode 100644 chalk/colorspaces/wetsticky/kis_wet_sticky_colorspace.cc create mode 100644 chalk/colorspaces/wetsticky/kis_wet_sticky_colorspace.cpp delete mode 100644 chalk/colorspaces/wetsticky/kis_ws_engine_filter.cc create mode 100644 chalk/colorspaces/wetsticky/kis_ws_engine_filter.cpp delete mode 100644 chalk/colorspaces/wetsticky/wet_sticky_plugin.cc create mode 100644 chalk/colorspaces/wetsticky/wet_sticky_plugin.cpp (limited to 'chalk/colorspaces/wetsticky') diff --git a/chalk/colorspaces/wetsticky/Makefile.am b/chalk/colorspaces/wetsticky/Makefile.am index 4ade368a..5d4e0289 100644 --- a/chalk/colorspaces/wetsticky/Makefile.am +++ b/chalk/colorspaces/wetsticky/Makefile.am @@ -12,7 +12,7 @@ INCLUDES = -I$(srcdir)/../../sdk \ kde_module_LTLIBRARIES = chalkwsplugin.la -chalkwsplugin_la_SOURCES = wet_sticky_plugin.cc kis_wet_sticky_colorspace.cc kis_ws_engine_filter.cc +chalkwsplugin_la_SOURCES = wet_sticky_plugin.cpp kis_wet_sticky_colorspace.cpp kis_ws_engine_filter.cpp noinst_HEADERS = wet_sticky_plugin.h kis_wet_sticky_colorspace.h kis_ws_engine_filter.h chalkwsplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) diff --git a/chalk/colorspaces/wetsticky/brushop/Makefile.am b/chalk/colorspaces/wetsticky/brushop/Makefile.am index 8df4d61e..eae064f8 100644 --- a/chalk/colorspaces/wetsticky/brushop/Makefile.am +++ b/chalk/colorspaces/wetsticky/brushop/Makefile.am @@ -13,8 +13,8 @@ INCLUDES = -I$(srcdir)/../../../sdk \ chalkwsbrushpaintop_la_SOURCES = \ - wsbrushpaintop_plugin.cc \ - kis_wsbrushop.cc + wsbrushpaintop_plugin.cpp \ + kis_wsbrushop.cpp noinst_HEADERS= \ wsbrushpaintop_plugin.h \ diff --git a/chalk/colorspaces/wetsticky/brushop/kis_wsbrushop.cc b/chalk/colorspaces/wetsticky/brushop/kis_wsbrushop.cc deleted file mode 100644 index ed828bf5..00000000 --- a/chalk/colorspaces/wetsticky/brushop/kis_wsbrushop.cc +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2005 Boudewijn Rempt - * - * 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 - -#include - -#include "kis_brush.h" -#include "kis_global.h" -#include "kis_paint_device.h" -#include "kis_painter.h" -#include "kis_types.h" -#include "kis_paintop.h" - -#include "kis_wsbrushop.h" - -KisPaintOp * KisWSBrushOpFactory::createOp(const KisPaintOpSettings */*settings*/, KisPainter * painter) -{ - KisPaintOp * op = new KisWSBrushOp(painter); - TQ_CHECK_PTR(op); - return op; -} - -KisWSBrushOp::KisWSBrushOp(KisPainter * painter) - : super(painter) -{ -} - -KisWSBrushOp::~KisWSBrushOp() -{ -} - -void KisWSBrushOp::paintAt(const KisPoint &pos, - const double pressure, - const double /*xTilt*/, - const double /*yTilt*/) -{ - // Painting should be implemented according to the following algorithm: - // retrieve brush - // if brush == mask - // retrieve mask - // else if brush == image - // retrieve image - // subsample (mask | image) for position -- pos should be double! - // apply filters to mask (colour | gradient | pattern | etc. - // composite filtered mask into temporary layer - // composite temporary layer into target layer - // @see: doc/brush.txt - - if (!m_painter -> device()) return; - - KisBrush *brush = m_painter -> brush(); - - Q_ASSERT(brush); - if (!brush) return; - - KisPaintDeviceSP device = m_painter -> device(); - - KisPoint hotSpot = brush -> hotSpot(pressure); - KisPoint pt = pos - hotSpot; - - // Split the coordinates into integer plus fractional parts. The integer - // is where the dab will be positioned and the fractional part determines - // the sub-pixel positioning. - TQ_INT32 x; - double xFraction; - TQ_INT32 y; - double yFraction; - - splitCoordinate(pt.x(), &x, &xFraction); - splitCoordinate(pt.y(), &y, &yFraction); - - KisLayerSP dab = 0; - - if (brush -> brushType() == IMAGE || brush -> brushType() == PIPE_IMAGE) { - dab = brush -> image(device -> colorSpace(), pressure, xFraction, yFraction); - } - else { - KisAlphaMaskSP mask = brush -> mask(pressure, xFraction, yFraction); - dab = computeDab(mask); - } - m_painter -> setPressure(pressure); - - TQRect dabRect = TQRect(0, 0, brush -> maskWidth(pressure), brush -> maskHeight(pressure)); - TQRect dstRect = TQRect(x, y, dabRect.width(), dabRect.height()); - - KisImage * image = device -> image(); - - if (image != 0) { - dstRect &= image -> bounds(); - } - - if (dstRect.isNull() || dstRect.isEmpty() || !dstRect.isValid()) return; - - TQ_INT32 sx = dstRect.x() - x; - TQ_INT32 sy = dstRect.y() - y; - TQ_INT32 sw = dstRect.width(); - TQ_INT32 sh = dstRect.height(); - - m_painter -> bltSelection(dstRect.x(), dstRect.y(), m_painter -> compositeOp(), dab.data(), m_painter -> opacity(), sx, sy, sw, sh); - m_painter -> addDirtyRect(dstRect); -} diff --git a/chalk/colorspaces/wetsticky/brushop/kis_wsbrushop.cpp b/chalk/colorspaces/wetsticky/brushop/kis_wsbrushop.cpp new file mode 100644 index 00000000..ed828bf5 --- /dev/null +++ b/chalk/colorspaces/wetsticky/brushop/kis_wsbrushop.cpp @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2005 Boudewijn Rempt + * + * 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 + +#include + +#include "kis_brush.h" +#include "kis_global.h" +#include "kis_paint_device.h" +#include "kis_painter.h" +#include "kis_types.h" +#include "kis_paintop.h" + +#include "kis_wsbrushop.h" + +KisPaintOp * KisWSBrushOpFactory::createOp(const KisPaintOpSettings */*settings*/, KisPainter * painter) +{ + KisPaintOp * op = new KisWSBrushOp(painter); + TQ_CHECK_PTR(op); + return op; +} + +KisWSBrushOp::KisWSBrushOp(KisPainter * painter) + : super(painter) +{ +} + +KisWSBrushOp::~KisWSBrushOp() +{ +} + +void KisWSBrushOp::paintAt(const KisPoint &pos, + const double pressure, + const double /*xTilt*/, + const double /*yTilt*/) +{ + // Painting should be implemented according to the following algorithm: + // retrieve brush + // if brush == mask + // retrieve mask + // else if brush == image + // retrieve image + // subsample (mask | image) for position -- pos should be double! + // apply filters to mask (colour | gradient | pattern | etc. + // composite filtered mask into temporary layer + // composite temporary layer into target layer + // @see: doc/brush.txt + + if (!m_painter -> device()) return; + + KisBrush *brush = m_painter -> brush(); + + Q_ASSERT(brush); + if (!brush) return; + + KisPaintDeviceSP device = m_painter -> device(); + + KisPoint hotSpot = brush -> hotSpot(pressure); + KisPoint pt = pos - hotSpot; + + // Split the coordinates into integer plus fractional parts. The integer + // is where the dab will be positioned and the fractional part determines + // the sub-pixel positioning. + TQ_INT32 x; + double xFraction; + TQ_INT32 y; + double yFraction; + + splitCoordinate(pt.x(), &x, &xFraction); + splitCoordinate(pt.y(), &y, &yFraction); + + KisLayerSP dab = 0; + + if (brush -> brushType() == IMAGE || brush -> brushType() == PIPE_IMAGE) { + dab = brush -> image(device -> colorSpace(), pressure, xFraction, yFraction); + } + else { + KisAlphaMaskSP mask = brush -> mask(pressure, xFraction, yFraction); + dab = computeDab(mask); + } + m_painter -> setPressure(pressure); + + TQRect dabRect = TQRect(0, 0, brush -> maskWidth(pressure), brush -> maskHeight(pressure)); + TQRect dstRect = TQRect(x, y, dabRect.width(), dabRect.height()); + + KisImage * image = device -> image(); + + if (image != 0) { + dstRect &= image -> bounds(); + } + + if (dstRect.isNull() || dstRect.isEmpty() || !dstRect.isValid()) return; + + TQ_INT32 sx = dstRect.x() - x; + TQ_INT32 sy = dstRect.y() - y; + TQ_INT32 sw = dstRect.width(); + TQ_INT32 sh = dstRect.height(); + + m_painter -> bltSelection(dstRect.x(), dstRect.y(), m_painter -> compositeOp(), dab.data(), m_painter -> opacity(), sx, sy, sw, sh); + m_painter -> addDirtyRect(dstRect); +} diff --git a/chalk/colorspaces/wetsticky/brushop/wsbrushpaintop_plugin.cc b/chalk/colorspaces/wetsticky/brushop/wsbrushpaintop_plugin.cc deleted file mode 100644 index 1f141bb4..00000000 --- a/chalk/colorspaces/wetsticky/brushop/wsbrushpaintop_plugin.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* - * wsbrushpaintop_plugin.cc -- Part of Chalk - * - * Copyright (c) 2005 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. - */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "kis_wsbrushop.h" - -#include "wsbrushpaintop_plugin.h" - -typedef KGenericFactory WSBrushPaintOpPluginFactory; -K_EXPORT_COMPONENT_FACTORY( chalkwsbrushpaintop, WSBrushPaintOpPluginFactory( "chalkcore" ) ) - - -WSBrushPaintOpPlugin::WSBrushPaintOpPlugin(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(WSBrushPaintOpPluginFactory::instance()); - - // This is not a gui plugin; only load it when the doc is created. - if ( parent->inherits("KisFactory") ) - { - KisPaintOpRegistry::instance() -> add ( new KisWSBrushOpFactory ); - } - -} - -WSBrushPaintOpPlugin::~WSBrushPaintOpPlugin() -{ -} - -#include "wsbrushpaintop_plugin.moc" diff --git a/chalk/colorspaces/wetsticky/brushop/wsbrushpaintop_plugin.cpp b/chalk/colorspaces/wetsticky/brushop/wsbrushpaintop_plugin.cpp new file mode 100644 index 00000000..97c892b2 --- /dev/null +++ b/chalk/colorspaces/wetsticky/brushop/wsbrushpaintop_plugin.cpp @@ -0,0 +1,56 @@ +/* + * wsbrushpaintop_plugin.cpp -- Part of Chalk + * + * Copyright (c) 2005 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. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "kis_wsbrushop.h" + +#include "wsbrushpaintop_plugin.h" + +typedef KGenericFactory WSBrushPaintOpPluginFactory; +K_EXPORT_COMPONENT_FACTORY( chalkwsbrushpaintop, WSBrushPaintOpPluginFactory( "chalkcore" ) ) + + +WSBrushPaintOpPlugin::WSBrushPaintOpPlugin(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(WSBrushPaintOpPluginFactory::instance()); + + // This is not a gui plugin; only load it when the doc is created. + if ( parent->inherits("KisFactory") ) + { + KisPaintOpRegistry::instance() -> add ( new KisWSBrushOpFactory ); + } + +} + +WSBrushPaintOpPlugin::~WSBrushPaintOpPlugin() +{ +} + +#include "wsbrushpaintop_plugin.moc" diff --git a/chalk/colorspaces/wetsticky/kis_wet_sticky_colorspace.cc b/chalk/colorspaces/wetsticky/kis_wet_sticky_colorspace.cc deleted file mode 100644 index 3e47114a..00000000 --- a/chalk/colorspaces/wetsticky/kis_wet_sticky_colorspace.cc +++ /dev/null @@ -1,605 +0,0 @@ -/* - * Copyright (c) 2005 Boudewijn Rempt - * - * 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 -#include - -#include -#include LCMS_HEADER - -#include - -#include -#include - -#include "kis_color_conversions.h" -#include "kis_abstract_colorspace.h" -#include "kis_colorspace_registry.h" -#include "kis_image.h" -#include "kis_wet_sticky_colorspace.h" -#include "kis_integer_maths.h" -#include "kis_types.h" -#include "kis_channelinfo.h" - -#define NOWSDEBUG - -using namespace WetAndSticky; - -enum WetStickyChannelIndex { - BLUE_CHANNEL_INDEX, - GREEN_CHANNEL_INDEX, - RED_CHANNEL_INDEX, - ALPHA_CHANNEL_INDEX, - HUE_CHANNEL_INDEX, - SATURATION_CHANNEL_INDEX, - LIGHTNESS_CHANNEL_INDEX, - LIQUID_CONTENT_CHANNEL_INDEX, - DRYING_RATE_CHANNEL_INDEX, - MISCIBILITY_CHANNEL_INDEX, - GRAVITATIONAL_DIRECTION_INDEX, - GRAVITATIONAL_STRENGTH_CHANNEL_INDEX, - ABSORBANCY_CHANNEL_INDEX, - PAINT_VOLUME_CHANNEL_INDEX -}; - -KisWetStickyColorSpace::KisWetStickyColorSpace() : - KisAbstractColorSpace(KisID("W&S", i18n("Wet & Sticky")), 0, icMaxEnumData) -{ - TQ_INT32 pos = 0; - - // Basic representational definition - m_channels.push_back(new KisChannelInfo(i18n("Blue"), "B", pos, COLOR, 1)); - m_channels.push_back(new KisChannelInfo(i18n("Green"), "G", ++pos, COLOR, 1)); - m_channels.push_back(new KisChannelInfo(i18n("Red"), "R", ++pos, COLOR, 1)); - m_channels.push_back(new KisChannelInfo(i18n("Alpha"), "A", ++pos, ALPHA, 1)); - - // Paint definition - m_channels.push_back(new KisChannelInfo(i18n("Hue"), "H", ++pos, COLOR, sizeof(float))); - m_channels.push_back(new KisChannelInfo(i18n("Saturation"), "S", pos+=sizeof(float) , COLOR, sizeof(float))); - m_channels.push_back(new KisChannelInfo(i18n("Lightness"), "L", pos+=sizeof(float), COLOR, sizeof(float))); - - m_channels.push_back(new KisChannelInfo(i18n("Liquid Content"), "Q", pos+=sizeof(float), SUBSTANCE, 1)); - m_channels.push_back(new KisChannelInfo(i18n("Drying Rate"), "D", ++pos, SUBSTANCE, 1)); - m_channels.push_back(new KisChannelInfo(i18n("Miscibility"), "M", ++pos, SUBSTANCE, 1)); - - // Substrate definition - m_channels.push_back(new KisChannelInfo(i18n("Gravitational Direction"), "Gd", ++pos, SUBSTRATE, sizeof(enumDirection))); - m_channels.push_back(new KisChannelInfo(i18n("Gravitational Strength"), "Gs", pos+=sizeof(enumDirection), SUBSTRATE, 1)); - - m_channels.push_back(new KisChannelInfo(i18n("Absorbency"), "Ad", ++pos, SUBSTRATE, 1)); - m_channels.push_back(new KisChannelInfo(i18n("Paint Volume"), "V", ++pos, SUBSTANCE, 1)); - - m_alphaPos = 3; - m_alphaSize = 1; - setDefaultProfile( 0 ); - -#ifdef WSDEBUG - TQValueVector_it it; - int i = 0; - for (it = m_channels.begin(); it != m_channels.end(); ++it) - { - KisChannelInfo * ch = (*it); - kdDebug(DBG_AREA_CMS) << "Channel: " << ch->name() << ", " << ch->pos() << ", " << i << "\n"; - ++i; - } - - kdDebug(DBG_AREA_CMS) << "Size of cell: " << sizeof(CELL) << "\n"; -#endif -} - - -KisWetStickyColorSpace::~KisWetStickyColorSpace() -{ -} - -void KisWetStickyColorSpace::fromTQColor(const TQColor& c, TQ_UINT8 *dst, KisProfile * profile) -{ - CELL_PTR p = (CELL_PTR) dst; - TQ_UINT8 r, g, b; - - r = c.red(); - g = c.green(); - b = c.blue(); - - p -> red = r; - p -> green = g; - p -> blue = b; - p -> alpha = OPACITY_OPAQUE; - - rgb_to_hls(r, g, b, &p->hue, &p->lightness, &p->saturation); - - p -> liquid_content = 0; - p -> drying_rate = 0; - p -> miscibility = 0; - - p -> direction = DOWN; - p -> strength = 10; - - p -> absorbancy = 10; - p -> volume = 0; - -#ifdef WSDEBUG - kdDebug(DBG_AREA_CMS) << "qcolor: " - << " r: " << c.red() << " b: " << c.blue() << " g: " << c.red() - << " native color: (" << TQString().setNum(p->red) << ", " - << TQString().setNum(p->green) << ", " - << TQString().setNum(p->blue) << ", " - << TQString().setNum(p->alpha) << ") " - << ", hls: (" << p->hue << ", " - << p->lightness << ", " - << p->saturation << ")\n"; -#endif -} - -void KisWetStickyColorSpace::fromTQColor(const TQColor& c, TQ_UINT8 opacity, TQ_UINT8 *dst, KisProfile * profile) -{ - CELL_PTR p = (CELL_PTR) dst; - TQ_UINT8 r, g, b; - - r = c.red(); - g = c.green(); - b = c.blue(); - - p -> red = r; - p -> green = g; - p -> blue = b; - p -> alpha = opacity; - rgb_to_hls(r, g, b, &p -> hue, &p -> lightness, &p -> saturation); - - p ->liquid_content = 0; - p ->drying_rate = 0; - p ->miscibility = 0; - - p -> direction = DOWN; - p -> strength = 10; - - p -> absorbancy = 10; - p -> volume = 0; - -#ifdef WSDEBUG - kdDebug(DBG_AREA_CMS) << "qcolor: " - << " r: " << c.red() << " b: " << c.blue() << " g: " << c.red() << " opacity: " << opacity - << " native color: (" << TQString().setNum(p->red) << ", " - << TQString().setNum(p->green) << ", " - << TQString().setNum(p->blue) << ", " - << TQString().setNum(p->alpha) << ") " - << ", hls: (" << p->hue << ", " - << p->lightness << ", " - << p->saturation << ")\n"; -#endif -} - -void KisWetStickyColorSpace::toTQColor(const TQ_UINT8 *src, TQColor *c, KisProfile * profile) -{ - CELL_PTR p = (CELL_PTR) src; - - c -> setRgb(p -> red, - p -> green, - p -> blue); -#ifdef WSDEBUG - kdDebug(DBG_AREA_CMS) << "Created qcolor from wet & sticky: " << " r: " << c->red() << " b: " << c->blue() << " g: " << c->red() << "\n"; -#endif -} - -void KisWetStickyColorSpace::toTQColor(const TQ_UINT8 *src, TQColor *c, TQ_UINT8 *opacity, KisProfile * profile) -{ - - CELL_PTR p = (CELL_PTR) src; - - c -> setRgb(p -> red, - p -> green, - p -> blue); - - *opacity = p -> alpha; -#ifdef WSDEBUG - kdDebug(DBG_AREA_CMS) << "Created qcolor from wet & sticky: " << " r: " << c->red() << " b: " << c->blue() << " g: " << c->red() << "\n"; -#endif -} - - - -KisPixelRO KisWetStickyColorSpace::toKisPixelRO(const TQ_UINT8 *src, KisProfile * profile) -{ - return KisPixelRO (src, src, this, profile); -} - -KisPixel KisWetStickyColorSpace::toKisPixel(TQ_UINT8 *src, KisProfile * profile) -{ - return KisPixel (src, src, this, profile); -} - -void KisWetStickyColorSpace::mixColors(const TQ_UINT8 **colors, const TQ_UINT8 *weights, TQ_UINT32 nColors, TQ_UINT8 *dst) const -{ -} - -TQ_UINT8 KisWetStickyColorSpace::getAlpha(const TQ_UINT8 *pixel) const -{ - return ((CELL_PTR)pixel)->alpha; -} - -void KisWetStickyColorSpace::setAlpha(TQ_UINT8 * pixels, TQ_UINT8 alpha, TQ_INT32 nPixels) const -{ - while (nPixels > 0) { - ((CELL_PTR)pixels)->alpha = alpha; - --nPixels; - pixels+=pixelSize(); - } -} - -void KisWetStickyColorSpace::applyAlphaU8Mask(TQ_UINT8 * pixels, TQ_UINT8 * alpha, TQ_INT32 nPixels) -{ -} - -void KisWetStickyColorSpace::applyInverseAlphaU8Mask(TQ_UINT8 * pixels, TQ_UINT8 * alpha, TQ_INT32 nPixels) -{ -} - -TQ_UINT8 KisWetStickyColorSpace::scaleToU8(const TQ_UINT8 * srcPixel, TQ_INT32 channelPos) -{ - return 0; -} - -TQ_UINT16 KisWetStickyColorSpace::scaleToU16(const TQ_UINT8 * srcPixel, TQ_INT32 channelPos) -{ - return 0; -} - - -TQValueVector KisWetStickyColorSpace::channels() const -{ - return m_channels; -} - -bool KisWetStickyColorSpace::hasAlpha() const -{ - return true; -} - -TQ_INT32 KisWetStickyColorSpace::nChannels() const -{ - return 14; -} - -TQ_INT32 KisWetStickyColorSpace::nColorChannels() const -{ - return 3; -} - -TQ_INT32 KisWetStickyColorSpace::nSubstanceChannels() const -{ - return 4; - -} - -TQ_INT32 KisWetStickyColorSpace::pixelSize() const -{ - return sizeof(CELL); -} - - -TQImage KisWetStickyColorSpace::convertToTQImage(const TQ_UINT8 *data, TQ_INT32 width, TQ_INT32 height, - KisProfile * /*srcProfile*/, KisProfile * /*dstProfile*/, - TQ_INT32 /*renderingIntent*/, float /*exposure*/) -{ - - TQImage img(width, height, 32, 0, TQImage::LittleEndian); - - TQ_INT32 i = 0; - uchar *j = img.bits(); - - CELL_PTR p = (CELL_PTR) data; - - while ( i < width * height) { - - const TQ_UINT8 PIXEL_BLUE = 0; - const TQ_UINT8 PIXEL_GREEN = 1; - const TQ_UINT8 PIXEL_RED = 2; - const TQ_UINT8 PIXEL_ALPHA = 3; - - *( j + PIXEL_ALPHA ) = p -> alpha; - *( j + PIXEL_RED ) = p -> red; - *( j + PIXEL_GREEN ) = p -> green; - *( j + PIXEL_BLUE ) = p -> blue; - - p++; - i++; - j += 4; // Because we're hard-coded 32 bits deep, 4 bytes - } - return img; -} - -bool KisWetStickyColorSpace::convertPixelsTo(const TQ_UINT8 * src, KisProfile * /*srcProfile*/, - TQ_UINT8 * dst, KisAbstractColorSpace * dstColorSpace, KisProfile * dstProfile, - TQ_UINT32 numPixels, - TQ_INT32 /*renderingIntent*/) -{ - TQ_INT32 dSize = dstColorSpace -> pixelSize(); - TQ_INT32 sSize = pixelSize(); - - TQ_UINT32 j = 0; - TQ_UINT32 i = 0; - TQColor c; - CELL_PTR cp; - while ( i < numPixels ) { - cp = (CELL_PTR) (src + i); - - c.setRgb(cp -> red, - cp -> green, - cp -> blue); - - dstColorSpace -> fromTQColor(c, cp -> alpha, (dst + j), dstProfile); - - i += sSize; - j += dSize; - - } - return true; - -} - -void KisWetStickyColorSpace::bitBlt(TQ_UINT8 *dst, - TQ_INT32 dstRowStride, - const TQ_UINT8 *src, - TQ_INT32 srcRowStride, - const TQ_UINT8 *mask, - TQ_INT32 maskRowStride, - TQ_UINT8 opacity, - TQ_INT32 rows, - TQ_INT32 cols, - const KisCompositeOp& op) -{ - switch (op.op()) { - case COMPOSITE_UNDEF: - // Undefined == no composition - break; - case COMPOSITE_OVER: - compositeOver(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity); - break; - case COMPOSITE_COPY: - default: - compositeCopy(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity); - break; - } - -} - - -void KisWetStickyColorSpace::compositeOver(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *maskRowStart, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT8 opacity) -{ - // XXX: This is basically the same as with rgb and used to composite layers for Composition for - // painting works differently - - - while (rows > 0) { - - const TQ_UINT8 *src = srcRowStart; - TQ_UINT8 *dst = dstRowStart; - const TQ_UINT8 *mask = maskRowStart; - - TQ_INT32 columns = numColumns; - - while (columns > 0) { - - CELL_PTR dstCell = (CELL_PTR) dst; - CELL_PTR srcCell = (CELL_PTR) src; - -#ifdef WSDEBUG - kdDebug(DBG_AREA_CMS) << "Source: " << rows << ", " << columns << " color: " << - srcCell->red << ", " << srcCell->blue << ", " << srcCell->green << ", " << srcCell->alpha << ", " << srcCell->volume << "\n"; - - - kdDebug(DBG_AREA_CMS) << "Destination: " << rows << ", " << columns << " color: " << - dstCell->red << ", " << dstCell->blue << ", " << dstCell->green << ", " << dstCell->alpha << ", " << dstCell->volume << "\n"; - -#endif - - TQ_UINT8 srcAlpha = srcCell->alpha; - - // apply the alphamask - if(mask != 0) - { - if(*mask != OPACITY_OPAQUE) - srcAlpha = UINT8_MULT(srcAlpha, *mask); - mask++; - } - - if (srcAlpha != OPACITY_TRANSPARENT) { - - if (opacity != OPACITY_OPAQUE) { - srcAlpha = UINT8_MULT(srcCell->alpha, opacity); - } - - if (srcAlpha == OPACITY_OPAQUE) { - memcpy(dst, src, 3); // XXX: First three bytes for rgb? - } else { - TQ_UINT8 dstAlpha = dstCell->alpha; - - TQ_UINT8 srcBlend; - - if (dstAlpha == OPACITY_OPAQUE) { - srcBlend = srcAlpha; - } else { - TQ_UINT8 newAlpha = dstAlpha + UINT8_MULT(OPACITY_OPAQUE - dstAlpha, srcAlpha); - dstCell->alpha = newAlpha; - - if (newAlpha != 0) { - srcBlend = UINT8_DIVIDE(srcAlpha, newAlpha); - } else { - srcBlend = srcAlpha; - } - } - - if (srcBlend == OPACITY_OPAQUE) { - memcpy(dst, src, 3); //XXX: First three bytes for rgb? - } else { - dstCell->red = UINT8_BLEND(srcCell->red, dstCell->red, srcBlend); - dstCell->green = UINT8_BLEND(srcCell->green, dstCell->green, srcBlend); - dstCell->blue = UINT8_BLEND(srcCell->blue, dstCell->blue, srcBlend); - } - } - } - columns--; - src += sizeof(CELL); - dst += sizeof(CELL); - } - rows--; - srcRowStart += srcRowStride; - dstRowStart += dstRowStride; - - if(maskRowStart) - maskRowStart += maskRowStride; - } - -} - -void KisWetStickyColorSpace::compositeCopy(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *mask, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT8 opacity) -{ - TQ_INT32 linesize = sizeof(CELL) * columns; - TQ_UINT8 *d; - const TQ_UINT8 *s; - d = dst; - s = src; - - while (rows-- > 0) { - memcpy(d, s, linesize); - d += dstRowStride; - s += srcRowStride; - } - -} - - -KisCompositeOpList KisWetStickyColorSpace::userVisiblecompositeOps() const -{ - KisCompositeOpList list; - - list.append(KisCompositeOp(COMPOSITE_OVER)); - - return list; -} - -TQString KisWetStickyColorSpace::channelValueText(const TQ_UINT8 *U8_pixel, TQ_UINT32 channelIndex) const -{ - Q_ASSERT(channelIndex < nChannels()); - const CELL *pixel = reinterpret_cast(U8_pixel); - - switch (channelIndex) { - case BLUE_CHANNEL_INDEX: - return TQString().setNum(pixel -> blue); - case GREEN_CHANNEL_INDEX: - return TQString().setNum(pixel -> green); - case RED_CHANNEL_INDEX: - return TQString().setNum(pixel -> red); - case ALPHA_CHANNEL_INDEX: - return TQString().setNum(pixel -> alpha); - case HUE_CHANNEL_INDEX: - return TQString().setNum(pixel -> hue); - case SATURATION_CHANNEL_INDEX: - return TQString().setNum(pixel -> saturation); - case LIGHTNESS_CHANNEL_INDEX: - return TQString().setNum(pixel -> lightness); - case LIQUID_CONTENT_CHANNEL_INDEX: - return TQString().setNum(pixel -> liquid_content); - case DRYING_RATE_CHANNEL_INDEX: - return TQString().setNum(pixel -> drying_rate); - case MISCIBILITY_CHANNEL_INDEX: - return TQString().setNum(pixel -> miscibility); - case GRAVITATIONAL_DIRECTION_INDEX: - { - switch (pixel -> direction) { - case UP: - return i18n("Up"); - case DOWN: - return i18n("Down"); - case LEFT: - return i18n("Left"); - case RIGHT: - return i18n("Right"); - default: - Q_ASSERT(false); - return TQString(); - } - } - case GRAVITATIONAL_STRENGTH_CHANNEL_INDEX: - return TQString().setNum(pixel -> strength); - case ABSORBANCY_CHANNEL_INDEX: - return TQString().setNum(pixel -> absorbancy); - case PAINT_VOLUME_CHANNEL_INDEX: - return TQString().setNum(pixel -> volume); - default: - Q_ASSERT(false); - return TQString(); - } -} - -TQString KisWetStickyColorSpace::normalisedChannelValueText(const TQ_UINT8 *U8_pixel, TQ_UINT32 channelIndex) const -{ - Q_ASSERT(channelIndex < nChannels()); - const CELL *pixel = reinterpret_cast(U8_pixel); - - //XXX: Are these right? - - switch (channelIndex) { - case BLUE_CHANNEL_INDEX: - return TQString().setNum(static_cast(pixel -> blue) / UINT8_MAX); - case GREEN_CHANNEL_INDEX: - return TQString().setNum(static_cast(pixel -> green) / UINT8_MAX); - case RED_CHANNEL_INDEX: - return TQString().setNum(static_cast(pixel -> red) / UINT8_MAX); - case ALPHA_CHANNEL_INDEX: - return TQString().setNum(static_cast(pixel -> alpha) / UINT8_MAX); - case HUE_CHANNEL_INDEX: - return TQString().setNum(pixel -> hue); - case SATURATION_CHANNEL_INDEX: - return TQString().setNum(pixel -> saturation); - case LIGHTNESS_CHANNEL_INDEX: - return TQString().setNum(pixel -> lightness); - case LIQUID_CONTENT_CHANNEL_INDEX: - return TQString().setNum(static_cast(pixel -> liquid_content) / UINT8_MAX); - case DRYING_RATE_CHANNEL_INDEX: - return TQString().setNum(static_cast(pixel -> drying_rate) / UINT8_MAX); - case MISCIBILITY_CHANNEL_INDEX: - return TQString().setNum(static_cast(pixel -> miscibility) / UINT8_MAX); - case GRAVITATIONAL_DIRECTION_INDEX: - { - switch (pixel -> direction) { - case UP: - return i18n("Up"); - case DOWN: - return i18n("Down"); - case LEFT: - return i18n("Left"); - case RIGHT: - return i18n("Right"); - default: - Q_ASSERT(false); - return TQString(); - } - } - case GRAVITATIONAL_STRENGTH_CHANNEL_INDEX: - return TQString().setNum(static_cast(pixel -> strength) / UINT8_MAX); - case ABSORBANCY_CHANNEL_INDEX: - return TQString().setNum(static_cast(pixel -> absorbancy) / UINT8_MAX); - case PAINT_VOLUME_CHANNEL_INDEX: - return TQString().setNum(static_cast(pixel -> volume) / UINT8_MAX); - default: - Q_ASSERT(false); - return TQString(); - } -} - diff --git a/chalk/colorspaces/wetsticky/kis_wet_sticky_colorspace.cpp b/chalk/colorspaces/wetsticky/kis_wet_sticky_colorspace.cpp new file mode 100644 index 00000000..3e47114a --- /dev/null +++ b/chalk/colorspaces/wetsticky/kis_wet_sticky_colorspace.cpp @@ -0,0 +1,605 @@ +/* + * Copyright (c) 2005 Boudewijn Rempt + * + * 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 +#include + +#include +#include LCMS_HEADER + +#include + +#include +#include + +#include "kis_color_conversions.h" +#include "kis_abstract_colorspace.h" +#include "kis_colorspace_registry.h" +#include "kis_image.h" +#include "kis_wet_sticky_colorspace.h" +#include "kis_integer_maths.h" +#include "kis_types.h" +#include "kis_channelinfo.h" + +#define NOWSDEBUG + +using namespace WetAndSticky; + +enum WetStickyChannelIndex { + BLUE_CHANNEL_INDEX, + GREEN_CHANNEL_INDEX, + RED_CHANNEL_INDEX, + ALPHA_CHANNEL_INDEX, + HUE_CHANNEL_INDEX, + SATURATION_CHANNEL_INDEX, + LIGHTNESS_CHANNEL_INDEX, + LIQUID_CONTENT_CHANNEL_INDEX, + DRYING_RATE_CHANNEL_INDEX, + MISCIBILITY_CHANNEL_INDEX, + GRAVITATIONAL_DIRECTION_INDEX, + GRAVITATIONAL_STRENGTH_CHANNEL_INDEX, + ABSORBANCY_CHANNEL_INDEX, + PAINT_VOLUME_CHANNEL_INDEX +}; + +KisWetStickyColorSpace::KisWetStickyColorSpace() : + KisAbstractColorSpace(KisID("W&S", i18n("Wet & Sticky")), 0, icMaxEnumData) +{ + TQ_INT32 pos = 0; + + // Basic representational definition + m_channels.push_back(new KisChannelInfo(i18n("Blue"), "B", pos, COLOR, 1)); + m_channels.push_back(new KisChannelInfo(i18n("Green"), "G", ++pos, COLOR, 1)); + m_channels.push_back(new KisChannelInfo(i18n("Red"), "R", ++pos, COLOR, 1)); + m_channels.push_back(new KisChannelInfo(i18n("Alpha"), "A", ++pos, ALPHA, 1)); + + // Paint definition + m_channels.push_back(new KisChannelInfo(i18n("Hue"), "H", ++pos, COLOR, sizeof(float))); + m_channels.push_back(new KisChannelInfo(i18n("Saturation"), "S", pos+=sizeof(float) , COLOR, sizeof(float))); + m_channels.push_back(new KisChannelInfo(i18n("Lightness"), "L", pos+=sizeof(float), COLOR, sizeof(float))); + + m_channels.push_back(new KisChannelInfo(i18n("Liquid Content"), "Q", pos+=sizeof(float), SUBSTANCE, 1)); + m_channels.push_back(new KisChannelInfo(i18n("Drying Rate"), "D", ++pos, SUBSTANCE, 1)); + m_channels.push_back(new KisChannelInfo(i18n("Miscibility"), "M", ++pos, SUBSTANCE, 1)); + + // Substrate definition + m_channels.push_back(new KisChannelInfo(i18n("Gravitational Direction"), "Gd", ++pos, SUBSTRATE, sizeof(enumDirection))); + m_channels.push_back(new KisChannelInfo(i18n("Gravitational Strength"), "Gs", pos+=sizeof(enumDirection), SUBSTRATE, 1)); + + m_channels.push_back(new KisChannelInfo(i18n("Absorbency"), "Ad", ++pos, SUBSTRATE, 1)); + m_channels.push_back(new KisChannelInfo(i18n("Paint Volume"), "V", ++pos, SUBSTANCE, 1)); + + m_alphaPos = 3; + m_alphaSize = 1; + setDefaultProfile( 0 ); + +#ifdef WSDEBUG + TQValueVector_it it; + int i = 0; + for (it = m_channels.begin(); it != m_channels.end(); ++it) + { + KisChannelInfo * ch = (*it); + kdDebug(DBG_AREA_CMS) << "Channel: " << ch->name() << ", " << ch->pos() << ", " << i << "\n"; + ++i; + } + + kdDebug(DBG_AREA_CMS) << "Size of cell: " << sizeof(CELL) << "\n"; +#endif +} + + +KisWetStickyColorSpace::~KisWetStickyColorSpace() +{ +} + +void KisWetStickyColorSpace::fromTQColor(const TQColor& c, TQ_UINT8 *dst, KisProfile * profile) +{ + CELL_PTR p = (CELL_PTR) dst; + TQ_UINT8 r, g, b; + + r = c.red(); + g = c.green(); + b = c.blue(); + + p -> red = r; + p -> green = g; + p -> blue = b; + p -> alpha = OPACITY_OPAQUE; + + rgb_to_hls(r, g, b, &p->hue, &p->lightness, &p->saturation); + + p -> liquid_content = 0; + p -> drying_rate = 0; + p -> miscibility = 0; + + p -> direction = DOWN; + p -> strength = 10; + + p -> absorbancy = 10; + p -> volume = 0; + +#ifdef WSDEBUG + kdDebug(DBG_AREA_CMS) << "qcolor: " + << " r: " << c.red() << " b: " << c.blue() << " g: " << c.red() + << " native color: (" << TQString().setNum(p->red) << ", " + << TQString().setNum(p->green) << ", " + << TQString().setNum(p->blue) << ", " + << TQString().setNum(p->alpha) << ") " + << ", hls: (" << p->hue << ", " + << p->lightness << ", " + << p->saturation << ")\n"; +#endif +} + +void KisWetStickyColorSpace::fromTQColor(const TQColor& c, TQ_UINT8 opacity, TQ_UINT8 *dst, KisProfile * profile) +{ + CELL_PTR p = (CELL_PTR) dst; + TQ_UINT8 r, g, b; + + r = c.red(); + g = c.green(); + b = c.blue(); + + p -> red = r; + p -> green = g; + p -> blue = b; + p -> alpha = opacity; + rgb_to_hls(r, g, b, &p -> hue, &p -> lightness, &p -> saturation); + + p ->liquid_content = 0; + p ->drying_rate = 0; + p ->miscibility = 0; + + p -> direction = DOWN; + p -> strength = 10; + + p -> absorbancy = 10; + p -> volume = 0; + +#ifdef WSDEBUG + kdDebug(DBG_AREA_CMS) << "qcolor: " + << " r: " << c.red() << " b: " << c.blue() << " g: " << c.red() << " opacity: " << opacity + << " native color: (" << TQString().setNum(p->red) << ", " + << TQString().setNum(p->green) << ", " + << TQString().setNum(p->blue) << ", " + << TQString().setNum(p->alpha) << ") " + << ", hls: (" << p->hue << ", " + << p->lightness << ", " + << p->saturation << ")\n"; +#endif +} + +void KisWetStickyColorSpace::toTQColor(const TQ_UINT8 *src, TQColor *c, KisProfile * profile) +{ + CELL_PTR p = (CELL_PTR) src; + + c -> setRgb(p -> red, + p -> green, + p -> blue); +#ifdef WSDEBUG + kdDebug(DBG_AREA_CMS) << "Created qcolor from wet & sticky: " << " r: " << c->red() << " b: " << c->blue() << " g: " << c->red() << "\n"; +#endif +} + +void KisWetStickyColorSpace::toTQColor(const TQ_UINT8 *src, TQColor *c, TQ_UINT8 *opacity, KisProfile * profile) +{ + + CELL_PTR p = (CELL_PTR) src; + + c -> setRgb(p -> red, + p -> green, + p -> blue); + + *opacity = p -> alpha; +#ifdef WSDEBUG + kdDebug(DBG_AREA_CMS) << "Created qcolor from wet & sticky: " << " r: " << c->red() << " b: " << c->blue() << " g: " << c->red() << "\n"; +#endif +} + + + +KisPixelRO KisWetStickyColorSpace::toKisPixelRO(const TQ_UINT8 *src, KisProfile * profile) +{ + return KisPixelRO (src, src, this, profile); +} + +KisPixel KisWetStickyColorSpace::toKisPixel(TQ_UINT8 *src, KisProfile * profile) +{ + return KisPixel (src, src, this, profile); +} + +void KisWetStickyColorSpace::mixColors(const TQ_UINT8 **colors, const TQ_UINT8 *weights, TQ_UINT32 nColors, TQ_UINT8 *dst) const +{ +} + +TQ_UINT8 KisWetStickyColorSpace::getAlpha(const TQ_UINT8 *pixel) const +{ + return ((CELL_PTR)pixel)->alpha; +} + +void KisWetStickyColorSpace::setAlpha(TQ_UINT8 * pixels, TQ_UINT8 alpha, TQ_INT32 nPixels) const +{ + while (nPixels > 0) { + ((CELL_PTR)pixels)->alpha = alpha; + --nPixels; + pixels+=pixelSize(); + } +} + +void KisWetStickyColorSpace::applyAlphaU8Mask(TQ_UINT8 * pixels, TQ_UINT8 * alpha, TQ_INT32 nPixels) +{ +} + +void KisWetStickyColorSpace::applyInverseAlphaU8Mask(TQ_UINT8 * pixels, TQ_UINT8 * alpha, TQ_INT32 nPixels) +{ +} + +TQ_UINT8 KisWetStickyColorSpace::scaleToU8(const TQ_UINT8 * srcPixel, TQ_INT32 channelPos) +{ + return 0; +} + +TQ_UINT16 KisWetStickyColorSpace::scaleToU16(const TQ_UINT8 * srcPixel, TQ_INT32 channelPos) +{ + return 0; +} + + +TQValueVector KisWetStickyColorSpace::channels() const +{ + return m_channels; +} + +bool KisWetStickyColorSpace::hasAlpha() const +{ + return true; +} + +TQ_INT32 KisWetStickyColorSpace::nChannels() const +{ + return 14; +} + +TQ_INT32 KisWetStickyColorSpace::nColorChannels() const +{ + return 3; +} + +TQ_INT32 KisWetStickyColorSpace::nSubstanceChannels() const +{ + return 4; + +} + +TQ_INT32 KisWetStickyColorSpace::pixelSize() const +{ + return sizeof(CELL); +} + + +TQImage KisWetStickyColorSpace::convertToTQImage(const TQ_UINT8 *data, TQ_INT32 width, TQ_INT32 height, + KisProfile * /*srcProfile*/, KisProfile * /*dstProfile*/, + TQ_INT32 /*renderingIntent*/, float /*exposure*/) +{ + + TQImage img(width, height, 32, 0, TQImage::LittleEndian); + + TQ_INT32 i = 0; + uchar *j = img.bits(); + + CELL_PTR p = (CELL_PTR) data; + + while ( i < width * height) { + + const TQ_UINT8 PIXEL_BLUE = 0; + const TQ_UINT8 PIXEL_GREEN = 1; + const TQ_UINT8 PIXEL_RED = 2; + const TQ_UINT8 PIXEL_ALPHA = 3; + + *( j + PIXEL_ALPHA ) = p -> alpha; + *( j + PIXEL_RED ) = p -> red; + *( j + PIXEL_GREEN ) = p -> green; + *( j + PIXEL_BLUE ) = p -> blue; + + p++; + i++; + j += 4; // Because we're hard-coded 32 bits deep, 4 bytes + } + return img; +} + +bool KisWetStickyColorSpace::convertPixelsTo(const TQ_UINT8 * src, KisProfile * /*srcProfile*/, + TQ_UINT8 * dst, KisAbstractColorSpace * dstColorSpace, KisProfile * dstProfile, + TQ_UINT32 numPixels, + TQ_INT32 /*renderingIntent*/) +{ + TQ_INT32 dSize = dstColorSpace -> pixelSize(); + TQ_INT32 sSize = pixelSize(); + + TQ_UINT32 j = 0; + TQ_UINT32 i = 0; + TQColor c; + CELL_PTR cp; + while ( i < numPixels ) { + cp = (CELL_PTR) (src + i); + + c.setRgb(cp -> red, + cp -> green, + cp -> blue); + + dstColorSpace -> fromTQColor(c, cp -> alpha, (dst + j), dstProfile); + + i += sSize; + j += dSize; + + } + return true; + +} + +void KisWetStickyColorSpace::bitBlt(TQ_UINT8 *dst, + TQ_INT32 dstRowStride, + const TQ_UINT8 *src, + TQ_INT32 srcRowStride, + const TQ_UINT8 *mask, + TQ_INT32 maskRowStride, + TQ_UINT8 opacity, + TQ_INT32 rows, + TQ_INT32 cols, + const KisCompositeOp& op) +{ + switch (op.op()) { + case COMPOSITE_UNDEF: + // Undefined == no composition + break; + case COMPOSITE_OVER: + compositeOver(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity); + break; + case COMPOSITE_COPY: + default: + compositeCopy(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity); + break; + } + +} + + +void KisWetStickyColorSpace::compositeOver(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *maskRowStart, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT8 opacity) +{ + // XXX: This is basically the same as with rgb and used to composite layers for Composition for + // painting works differently + + + while (rows > 0) { + + const TQ_UINT8 *src = srcRowStart; + TQ_UINT8 *dst = dstRowStart; + const TQ_UINT8 *mask = maskRowStart; + + TQ_INT32 columns = numColumns; + + while (columns > 0) { + + CELL_PTR dstCell = (CELL_PTR) dst; + CELL_PTR srcCell = (CELL_PTR) src; + +#ifdef WSDEBUG + kdDebug(DBG_AREA_CMS) << "Source: " << rows << ", " << columns << " color: " << + srcCell->red << ", " << srcCell->blue << ", " << srcCell->green << ", " << srcCell->alpha << ", " << srcCell->volume << "\n"; + + + kdDebug(DBG_AREA_CMS) << "Destination: " << rows << ", " << columns << " color: " << + dstCell->red << ", " << dstCell->blue << ", " << dstCell->green << ", " << dstCell->alpha << ", " << dstCell->volume << "\n"; + +#endif + + TQ_UINT8 srcAlpha = srcCell->alpha; + + // apply the alphamask + if(mask != 0) + { + if(*mask != OPACITY_OPAQUE) + srcAlpha = UINT8_MULT(srcAlpha, *mask); + mask++; + } + + if (srcAlpha != OPACITY_TRANSPARENT) { + + if (opacity != OPACITY_OPAQUE) { + srcAlpha = UINT8_MULT(srcCell->alpha, opacity); + } + + if (srcAlpha == OPACITY_OPAQUE) { + memcpy(dst, src, 3); // XXX: First three bytes for rgb? + } else { + TQ_UINT8 dstAlpha = dstCell->alpha; + + TQ_UINT8 srcBlend; + + if (dstAlpha == OPACITY_OPAQUE) { + srcBlend = srcAlpha; + } else { + TQ_UINT8 newAlpha = dstAlpha + UINT8_MULT(OPACITY_OPAQUE - dstAlpha, srcAlpha); + dstCell->alpha = newAlpha; + + if (newAlpha != 0) { + srcBlend = UINT8_DIVIDE(srcAlpha, newAlpha); + } else { + srcBlend = srcAlpha; + } + } + + if (srcBlend == OPACITY_OPAQUE) { + memcpy(dst, src, 3); //XXX: First three bytes for rgb? + } else { + dstCell->red = UINT8_BLEND(srcCell->red, dstCell->red, srcBlend); + dstCell->green = UINT8_BLEND(srcCell->green, dstCell->green, srcBlend); + dstCell->blue = UINT8_BLEND(srcCell->blue, dstCell->blue, srcBlend); + } + } + } + columns--; + src += sizeof(CELL); + dst += sizeof(CELL); + } + rows--; + srcRowStart += srcRowStride; + dstRowStart += dstRowStride; + + if(maskRowStart) + maskRowStart += maskRowStride; + } + +} + +void KisWetStickyColorSpace::compositeCopy(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *mask, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT8 opacity) +{ + TQ_INT32 linesize = sizeof(CELL) * columns; + TQ_UINT8 *d; + const TQ_UINT8 *s; + d = dst; + s = src; + + while (rows-- > 0) { + memcpy(d, s, linesize); + d += dstRowStride; + s += srcRowStride; + } + +} + + +KisCompositeOpList KisWetStickyColorSpace::userVisiblecompositeOps() const +{ + KisCompositeOpList list; + + list.append(KisCompositeOp(COMPOSITE_OVER)); + + return list; +} + +TQString KisWetStickyColorSpace::channelValueText(const TQ_UINT8 *U8_pixel, TQ_UINT32 channelIndex) const +{ + Q_ASSERT(channelIndex < nChannels()); + const CELL *pixel = reinterpret_cast(U8_pixel); + + switch (channelIndex) { + case BLUE_CHANNEL_INDEX: + return TQString().setNum(pixel -> blue); + case GREEN_CHANNEL_INDEX: + return TQString().setNum(pixel -> green); + case RED_CHANNEL_INDEX: + return TQString().setNum(pixel -> red); + case ALPHA_CHANNEL_INDEX: + return TQString().setNum(pixel -> alpha); + case HUE_CHANNEL_INDEX: + return TQString().setNum(pixel -> hue); + case SATURATION_CHANNEL_INDEX: + return TQString().setNum(pixel -> saturation); + case LIGHTNESS_CHANNEL_INDEX: + return TQString().setNum(pixel -> lightness); + case LIQUID_CONTENT_CHANNEL_INDEX: + return TQString().setNum(pixel -> liquid_content); + case DRYING_RATE_CHANNEL_INDEX: + return TQString().setNum(pixel -> drying_rate); + case MISCIBILITY_CHANNEL_INDEX: + return TQString().setNum(pixel -> miscibility); + case GRAVITATIONAL_DIRECTION_INDEX: + { + switch (pixel -> direction) { + case UP: + return i18n("Up"); + case DOWN: + return i18n("Down"); + case LEFT: + return i18n("Left"); + case RIGHT: + return i18n("Right"); + default: + Q_ASSERT(false); + return TQString(); + } + } + case GRAVITATIONAL_STRENGTH_CHANNEL_INDEX: + return TQString().setNum(pixel -> strength); + case ABSORBANCY_CHANNEL_INDEX: + return TQString().setNum(pixel -> absorbancy); + case PAINT_VOLUME_CHANNEL_INDEX: + return TQString().setNum(pixel -> volume); + default: + Q_ASSERT(false); + return TQString(); + } +} + +TQString KisWetStickyColorSpace::normalisedChannelValueText(const TQ_UINT8 *U8_pixel, TQ_UINT32 channelIndex) const +{ + Q_ASSERT(channelIndex < nChannels()); + const CELL *pixel = reinterpret_cast(U8_pixel); + + //XXX: Are these right? + + switch (channelIndex) { + case BLUE_CHANNEL_INDEX: + return TQString().setNum(static_cast(pixel -> blue) / UINT8_MAX); + case GREEN_CHANNEL_INDEX: + return TQString().setNum(static_cast(pixel -> green) / UINT8_MAX); + case RED_CHANNEL_INDEX: + return TQString().setNum(static_cast(pixel -> red) / UINT8_MAX); + case ALPHA_CHANNEL_INDEX: + return TQString().setNum(static_cast(pixel -> alpha) / UINT8_MAX); + case HUE_CHANNEL_INDEX: + return TQString().setNum(pixel -> hue); + case SATURATION_CHANNEL_INDEX: + return TQString().setNum(pixel -> saturation); + case LIGHTNESS_CHANNEL_INDEX: + return TQString().setNum(pixel -> lightness); + case LIQUID_CONTENT_CHANNEL_INDEX: + return TQString().setNum(static_cast(pixel -> liquid_content) / UINT8_MAX); + case DRYING_RATE_CHANNEL_INDEX: + return TQString().setNum(static_cast(pixel -> drying_rate) / UINT8_MAX); + case MISCIBILITY_CHANNEL_INDEX: + return TQString().setNum(static_cast(pixel -> miscibility) / UINT8_MAX); + case GRAVITATIONAL_DIRECTION_INDEX: + { + switch (pixel -> direction) { + case UP: + return i18n("Up"); + case DOWN: + return i18n("Down"); + case LEFT: + return i18n("Left"); + case RIGHT: + return i18n("Right"); + default: + Q_ASSERT(false); + return TQString(); + } + } + case GRAVITATIONAL_STRENGTH_CHANNEL_INDEX: + return TQString().setNum(static_cast(pixel -> strength) / UINT8_MAX); + case ABSORBANCY_CHANNEL_INDEX: + return TQString().setNum(static_cast(pixel -> absorbancy) / UINT8_MAX); + case PAINT_VOLUME_CHANNEL_INDEX: + return TQString().setNum(static_cast(pixel -> volume) / UINT8_MAX); + default: + Q_ASSERT(false); + return TQString(); + } +} + diff --git a/chalk/colorspaces/wetsticky/kis_ws_engine_filter.cc b/chalk/colorspaces/wetsticky/kis_ws_engine_filter.cc deleted file mode 100644 index c53f6ea0..00000000 --- a/chalk/colorspaces/wetsticky/kis_ws_engine_filter.cc +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2005 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. - */ -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "kis_ws_engine_filter.h" -#include "kis_wet_sticky_colorspace.h" - -/** - * The Wet & Sticky Engine filter is based on the wet & sticky model - * for computer painting designed by Tunde Cockshott and implemented - * by David England and Kevin Waite. - * - * The filter implements the engine that moves the paint according to - * gravity, viscosity and absorbency. - * - */ -KisWSEngineFilter::KisWSEngineFilter() : KisFilter(id(), "", i18n("&Wet & Sticky paint engine...")) -{ -} - - -/** - * Sets the POINT giving the coordinate location of the next - * cell on the canvas to be visited. There is an even probability - * of each cell being visited. - */ -TQPoint next_cell(TQ_UINT32 width, TQ_UINT32 height) -{ - return TQPoint(random() * width, random() * height); -} - -void single_step(KisColorSpace * cs, KisPaintDeviceSP src, KisPaintDeviceSP dst, const TQRect & rect, bool native) -{ - using namespace WetAndSticky; - - - TQPoint p = next_cell( rect.width(), rect.height() ); - - // XXX: We could optimize by randomly doing lines of 64 pixels - // -- maybe that would be enough to avoid the windscreen wiper - // effect. - KisHLineIterator iter = src -> createHLineIterator(p.x(), p.y(), 1, false); - - TQ_UINT8 *orig = iter.rawData(); - TQ_UINT8 *pix = orig; - - if (!orig) return; - - if (!native ) { - TQColor c; - TQ_UINT8 opacity; - - src -> colorSpace() -> toTQColor(pix, &c, &opacity); - TQ_UINT8 *pix = new TQ_UINT8[sizeof( cell )]; - TQ_CHECK_PTR(pix); - - cs -> fromTQColor(c, opacity, pix); - } - - // Process - - CELL_PTR c = ( CELL_PTR )pix; - - - if ( !native ) { - // Set RGBA back - } - -} - -void KisWSEngineFilter::process(KisPaintDeviceSP src, KisPaintDeviceSP dst, KisFilterConfiguration* configuration, const TQRect& rect) -{ - - m_src = src; - m_dst = dst; - m_cfg = ( KisWSEngineFilterConfiguration * )configuration; - m_rect = rect; - - - kdDebug(DBG_AREA_FILTERS) << "WSEnginefilter called!\n"; - TQTime t; - t.restart(); - - // Two possibilities: we have our own, cool w&s pixel, and - // then we have real data to mess with, or we're filtering a - // boring shoup-model paint device and we can only work by - // synthesizing w&s pixels. - bool native = false; - // XXX: We need a better way to ID color strategies - if ( src -> colorSpace() -> id() == KisID("W&S","") ) native = true; - - // XXX: We need a better way to ID color strategies - KisColorSpace * cs = KisColorSpaceRegistry::instance()->get("W&S"); - - TQ_UINT32 pixels = 400; //m_cfg -> pixels(); - - kdDebug(DBG_AREA_FILTERS) << "Going to singlestep " << pixels << " pixels.\n"; - - // Determine whether we want an infinite loop - if ( pixels == 0 ) { - while ( true ) - single_step (cs, src, dst, rect, native); - } - // Or not. - else { - for ( TQ_UINT32 i = 0; i < pixels; ++i ) { - single_step (cs, src, dst, rect, native); - } - } - kdDebug(DBG_AREA_FILTERS) << "Done in " << t.elapsed() << " ms\n"; - -} - -KisFilterConfigWidget * KisWSEngineFilter::createConfigurationWidget(TQWidget* parent, KisPaintDeviceSP dev) -{ -// KisWSEngineFilterConfigurationWidget* kefcw = new KisWSEngineFilterConfigurationWidget(this,parent, ""); -// kdDebug(DBG_AREA_FILTERS) << kefcw << endl; -// return kefcw ; - return 0; -} - -KisFilterConfiguration* KisWSEngineFilter::configuration(TQWidget* nwidget, KisPaintDeviceSP dev) -{ -// KisWSEngineFilterConfigurationWidget* widget = (KisWSEngineFilterConfigurationWidget*) nwidget; - -// if( widget == 0 ) -// { -// return new KisWSEngineFilterConfiguration(30); -// } else { -// TQ_UINT32 depth = widget -> baseWidget() -> depthSpinBox -> value(); - -// return new KisWSEngineFilterConfiguration(depth); -// } - - - return new KisWSEngineFilterConfiguration( m_rect.height() * m_rect.width() ); -} - diff --git a/chalk/colorspaces/wetsticky/kis_ws_engine_filter.cpp b/chalk/colorspaces/wetsticky/kis_ws_engine_filter.cpp new file mode 100644 index 00000000..c53f6ea0 --- /dev/null +++ b/chalk/colorspaces/wetsticky/kis_ws_engine_filter.cpp @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2005 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. + */ +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "kis_ws_engine_filter.h" +#include "kis_wet_sticky_colorspace.h" + +/** + * The Wet & Sticky Engine filter is based on the wet & sticky model + * for computer painting designed by Tunde Cockshott and implemented + * by David England and Kevin Waite. + * + * The filter implements the engine that moves the paint according to + * gravity, viscosity and absorbency. + * + */ +KisWSEngineFilter::KisWSEngineFilter() : KisFilter(id(), "", i18n("&Wet & Sticky paint engine...")) +{ +} + + +/** + * Sets the POINT giving the coordinate location of the next + * cell on the canvas to be visited. There is an even probability + * of each cell being visited. + */ +TQPoint next_cell(TQ_UINT32 width, TQ_UINT32 height) +{ + return TQPoint(random() * width, random() * height); +} + +void single_step(KisColorSpace * cs, KisPaintDeviceSP src, KisPaintDeviceSP dst, const TQRect & rect, bool native) +{ + using namespace WetAndSticky; + + + TQPoint p = next_cell( rect.width(), rect.height() ); + + // XXX: We could optimize by randomly doing lines of 64 pixels + // -- maybe that would be enough to avoid the windscreen wiper + // effect. + KisHLineIterator iter = src -> createHLineIterator(p.x(), p.y(), 1, false); + + TQ_UINT8 *orig = iter.rawData(); + TQ_UINT8 *pix = orig; + + if (!orig) return; + + if (!native ) { + TQColor c; + TQ_UINT8 opacity; + + src -> colorSpace() -> toTQColor(pix, &c, &opacity); + TQ_UINT8 *pix = new TQ_UINT8[sizeof( cell )]; + TQ_CHECK_PTR(pix); + + cs -> fromTQColor(c, opacity, pix); + } + + // Process + + CELL_PTR c = ( CELL_PTR )pix; + + + if ( !native ) { + // Set RGBA back + } + +} + +void KisWSEngineFilter::process(KisPaintDeviceSP src, KisPaintDeviceSP dst, KisFilterConfiguration* configuration, const TQRect& rect) +{ + + m_src = src; + m_dst = dst; + m_cfg = ( KisWSEngineFilterConfiguration * )configuration; + m_rect = rect; + + + kdDebug(DBG_AREA_FILTERS) << "WSEnginefilter called!\n"; + TQTime t; + t.restart(); + + // Two possibilities: we have our own, cool w&s pixel, and + // then we have real data to mess with, or we're filtering a + // boring shoup-model paint device and we can only work by + // synthesizing w&s pixels. + bool native = false; + // XXX: We need a better way to ID color strategies + if ( src -> colorSpace() -> id() == KisID("W&S","") ) native = true; + + // XXX: We need a better way to ID color strategies + KisColorSpace * cs = KisColorSpaceRegistry::instance()->get("W&S"); + + TQ_UINT32 pixels = 400; //m_cfg -> pixels(); + + kdDebug(DBG_AREA_FILTERS) << "Going to singlestep " << pixels << " pixels.\n"; + + // Determine whether we want an infinite loop + if ( pixels == 0 ) { + while ( true ) + single_step (cs, src, dst, rect, native); + } + // Or not. + else { + for ( TQ_UINT32 i = 0; i < pixels; ++i ) { + single_step (cs, src, dst, rect, native); + } + } + kdDebug(DBG_AREA_FILTERS) << "Done in " << t.elapsed() << " ms\n"; + +} + +KisFilterConfigWidget * KisWSEngineFilter::createConfigurationWidget(TQWidget* parent, KisPaintDeviceSP dev) +{ +// KisWSEngineFilterConfigurationWidget* kefcw = new KisWSEngineFilterConfigurationWidget(this,parent, ""); +// kdDebug(DBG_AREA_FILTERS) << kefcw << endl; +// return kefcw ; + return 0; +} + +KisFilterConfiguration* KisWSEngineFilter::configuration(TQWidget* nwidget, KisPaintDeviceSP dev) +{ +// KisWSEngineFilterConfigurationWidget* widget = (KisWSEngineFilterConfigurationWidget*) nwidget; + +// if( widget == 0 ) +// { +// return new KisWSEngineFilterConfiguration(30); +// } else { +// TQ_UINT32 depth = widget -> baseWidget() -> depthSpinBox -> value(); + +// return new KisWSEngineFilterConfiguration(depth); +// } + + + return new KisWSEngineFilterConfiguration( m_rect.height() * m_rect.width() ); +} + diff --git a/chalk/colorspaces/wetsticky/wet_sticky_plugin.cc b/chalk/colorspaces/wetsticky/wet_sticky_plugin.cc deleted file mode 100644 index 76dee20e..00000000 --- a/chalk/colorspaces/wetsticky/wet_sticky_plugin.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* - * wet_sticky_plugin.cc -- Part of Chalk - * - * Copyright (c) 2005 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. - */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "wet_sticky_plugin.h" - -#include "kis_wet_sticky_colorspace.h" -#include "kis_ws_engine_filter.h" - -typedef KGenericFactory WetStickyPluginFactory; -K_EXPORT_COMPONENT_FACTORY( chalkwsplugin, WetStickyPluginFactory( "chalkcore" ) ) - - -WetStickyPlugin::WetStickyPlugin(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(WetStickyPluginFactory::instance()); - - // This is not a gui plugin; only load it when the doc is created. - if ( parent->inherits("KisFactory") ) - { - KisColorSpace * colorSpaceWS = new KisWetStickyColorSpace(); - TQ_CHECK_PTR(colorSpaceWS); - KisColorSpaceRegistry::instance() -> add(colorSpaceWS); - KisFilterRegistry::instance()->add(new KisWSEngineFilter()); - } - -} - -WetStickyPlugin::~WetStickyPlugin() -{ -} - -#include "wet_sticky_plugin.moc" diff --git a/chalk/colorspaces/wetsticky/wet_sticky_plugin.cpp b/chalk/colorspaces/wetsticky/wet_sticky_plugin.cpp new file mode 100644 index 00000000..e56e4cc8 --- /dev/null +++ b/chalk/colorspaces/wetsticky/wet_sticky_plugin.cpp @@ -0,0 +1,60 @@ +/* + * wet_sticky_plugin.cpp -- Part of Chalk + * + * Copyright (c) 2005 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. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "wet_sticky_plugin.h" + +#include "kis_wet_sticky_colorspace.h" +#include "kis_ws_engine_filter.h" + +typedef KGenericFactory WetStickyPluginFactory; +K_EXPORT_COMPONENT_FACTORY( chalkwsplugin, WetStickyPluginFactory( "chalkcore" ) ) + + +WetStickyPlugin::WetStickyPlugin(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(WetStickyPluginFactory::instance()); + + // This is not a gui plugin; only load it when the doc is created. + if ( parent->inherits("KisFactory") ) + { + KisColorSpace * colorSpaceWS = new KisWetStickyColorSpace(); + TQ_CHECK_PTR(colorSpaceWS); + KisColorSpaceRegistry::instance() -> add(colorSpaceWS); + KisFilterRegistry::instance()->add(new KisWSEngineFilter()); + } + +} + +WetStickyPlugin::~WetStickyPlugin() +{ +} + +#include "wet_sticky_plugin.moc" -- cgit v1.2.1