diff options
Diffstat (limited to 'krita/colorspaces/ycbcr_u8')
-rw-r--r-- | krita/colorspaces/ycbcr_u8/Makefile.am | 29 | ||||
-rw-r--r-- | krita/colorspaces/ycbcr_u8/kis_ycbcr_u8_colorspace.cc | 344 | ||||
-rw-r--r-- | krita/colorspaces/ycbcr_u8/kis_ycbcr_u8_colorspace.h | 144 | ||||
-rw-r--r-- | krita/colorspaces/ycbcr_u8/krita_ycbcr_u8_plugin.desktop | 71 | ||||
-rw-r--r-- | krita/colorspaces/ycbcr_u8/ycbcr_u8_plugin.cc | 62 | ||||
-rw-r--r-- | krita/colorspaces/ycbcr_u8/ycbcr_u8_plugin.h | 37 |
6 files changed, 687 insertions, 0 deletions
diff --git a/krita/colorspaces/ycbcr_u8/Makefile.am b/krita/colorspaces/ycbcr_u8/Makefile.am new file mode 100644 index 00000000..bb534bc1 --- /dev/null +++ b/krita/colorspaces/ycbcr_u8/Makefile.am @@ -0,0 +1,29 @@ +# Install the desktop file needed to detect the plugin + + +INCLUDES = -I$(srcdir)/../../sdk \ + -I$(srcdir)/../../kritacolor/color_strategy/ \ + -I$(srcdir)/../../kritacolor/ \ + $(KOFFICE_INCLUDES) \ + $(all_includes) + +lib_LTLIBRARIES = libkrita_ycbcr_u8.la + +libkrita_ycbcr_u8_la_LDFLAGS = $(all_libraries) +libkrita_ycbcr_u8_la_LIBADD = ../../kritacolor/libkritacolor.la + +# Install this plugin in the KDE modules directory +kde_module_LTLIBRARIES = krita_ycbcr_u8_plugin.la + +# Srcs for the plugin +krita_ycbcr_u8_plugin_la_SOURCES = ycbcr_u8_plugin.cc +noinst_HEADERS = ycbcr_u8_plugin.h kis_ycbcr_u8_colorspace.h + +krita_ycbcr_u8_plugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) +krita_ycbcr_u8_plugin_la_LIBADD = libkrita_ycbcr_u8.la ../../kritacolor/libkritacolor.la + +METASOURCES = AUTO + + +libkrita_ycbcr_u8_la_SOURCES = kis_ycbcr_u8_colorspace.cc +kde_services_DATA = krita_ycbcr_u8_plugin.desktop diff --git a/krita/colorspaces/ycbcr_u8/kis_ycbcr_u8_colorspace.cc b/krita/colorspaces/ycbcr_u8/kis_ycbcr_u8_colorspace.cc new file mode 100644 index 00000000..7c6707c5 --- /dev/null +++ b/krita/colorspaces/ycbcr_u8/kis_ycbcr_u8_colorspace.cc @@ -0,0 +1,344 @@ +/* + * Copyright (c) 2006 Cyrille Berger <[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 "kis_ycbcr_u8_colorspace.h" + +#include <qimage.h> + +#include <kis_integer_maths.h> + +const Q_INT32 MAX_CHANNEL_YCbCr = 3; +const Q_INT32 MAX_CHANNEL_YCbCrA = 4; + +KisYCbCrU8ColorSpace::KisYCbCrU8ColorSpace(KisColorSpaceFactoryRegistry* parent, KisProfile* /*p*/) + : KisU8BaseColorSpace(KisID("YCbCrAU8", i18n("YCbCr (8-bit integer/channel)")), TYPE_YCbCr_8, icSigYCbCrData, parent, 0) +{ + m_channels.push_back(new KisChannelInfo(i18n("Y"), "Y", PIXEL_Y * sizeof(Q_UINT8), KisChannelInfo::COLOR, KisChannelInfo::UINT8, sizeof(Q_UINT8))); + m_channels.push_back(new KisChannelInfo(i18n("Cb"), "Cb", PIXEL_Cb * sizeof(Q_UINT8), KisChannelInfo::COLOR, KisChannelInfo::UINT8, sizeof(Q_UINT8))); + m_channels.push_back(new KisChannelInfo(i18n("Cr"), "Cr", PIXEL_Cr * sizeof(Q_UINT8), KisChannelInfo::COLOR, KisChannelInfo::UINT8, sizeof(Q_UINT8))); + m_channels.push_back(new KisChannelInfo(i18n("Alpha"), "A", PIXEL_ALPHA * sizeof(Q_UINT8), KisChannelInfo::ALPHA, KisChannelInfo::UINT8, sizeof(Q_UINT8))); + + m_alphaPos = PIXEL_ALPHA * sizeof(Q_UINT8); + KisAbstractColorSpace::init(); +} + + +KisYCbCrU8ColorSpace::~KisYCbCrU8ColorSpace() +{ +} + +void KisYCbCrU8ColorSpace::setPixel(Q_UINT8 *dst, Q_UINT8 Y, Q_UINT8 Cb, Q_UINT8 Cr, Q_UINT8 alpha) const +{ + Pixel *dstPixel = reinterpret_cast<Pixel *>(dst); + + dstPixel->Y = Y; + dstPixel->Cb = Cb; + dstPixel->Cr = Cr; + dstPixel->alpha = alpha; +} + +void KisYCbCrU8ColorSpace::getPixel(const Q_UINT8 *src, Q_UINT8 *Y, Q_UINT8 *Cb, Q_UINT8 *Cr, Q_UINT8 *alpha) const +{ + const Pixel *srcPixel = reinterpret_cast<const Pixel *>(src); + + *Y = srcPixel->Y; + *Cb = srcPixel->Cb; + *Cr = srcPixel->Cr; + *alpha = srcPixel->alpha; + +} + +void KisYCbCrU8ColorSpace::fromQColor(const QColor& c, Q_UINT8 *dstU8, KisProfile * profile ) +{ + if(getProfile()) + { + KisU8BaseColorSpace::fromQColor(c, dstU8, profile); + } else { + Pixel *dst = reinterpret_cast<Pixel *>(dstU8); + dst->Y = computeY( c.red(), c.green(), c.blue()); + dst->Cb = computeCb( c.red(), c.green(), c.blue()); + dst->Cr = computeCr( c.red(), c.green(), c.blue()); + } +} + +void KisYCbCrU8ColorSpace::fromQColor(const QColor& c, Q_UINT8 opacity, Q_UINT8 *dstU8, KisProfile * profile ) +{ + if(getProfile()) + { + KisU8BaseColorSpace::fromQColor(c, opacity, dstU8, profile); + } else { + Pixel *dst = reinterpret_cast<Pixel *>(dstU8); + dst->Y = computeY( c.red(), c.green(), c.blue()); + dst->Cb = computeCb( c.red(), c.green(), c.blue()); + dst->Cr = computeCr( c.red(), c.green(), c.blue()); + dst->alpha = opacity; + } +} + +void KisYCbCrU8ColorSpace::toQColor(const Q_UINT8 *srcU8, QColor *c, KisProfile * profile) +{ + if(getProfile()) + { + KisU8BaseColorSpace::toQColor(srcU8, c, profile); + + } else { + const Pixel *src = reinterpret_cast<const Pixel *>(srcU8); + c->setRgb(computeRed(src->Y,src->Cb,src->Cr), computeGreen(src->Y,src->Cb,src->Cr), computeBlue(src->Y,src->Cb,src->Cr)); + } +} + +void KisYCbCrU8ColorSpace::toQColor(const Q_UINT8 *srcU8, QColor *c, Q_UINT8 *opacity, KisProfile * profile) +{ + if(getProfile()) + { + KisU8BaseColorSpace::toQColor(srcU8, c, opacity, profile); + } else { + const Pixel *src = reinterpret_cast<const Pixel *>(srcU8); + c->setRgb(computeRed(src->Y,src->Cb,src->Cr), computeGreen(src->Y,src->Cb,src->Cr), computeBlue(src->Y,src->Cb,src->Cr)); + *opacity = src->alpha; + } +} + +Q_UINT8 KisYCbCrU8ColorSpace::difference(const Q_UINT8 *src1U8, const Q_UINT8 *src2U8) +{ + if(getProfile()) + return KisU8BaseColorSpace::difference(src1U8, src2U8); + const Pixel *src1 = reinterpret_cast<const Pixel *>(src1U8); + const Pixel *src2 = reinterpret_cast<const Pixel *>(src2U8); + + return QMAX(QABS(src2->Y - src1->Y), QMAX(QABS(src2->Cb - src1->Cb), QABS(src2->Cr - src1->Cr))); + +} + +void KisYCbCrU8ColorSpace::mixColors(const Q_UINT8 **colors, const Q_UINT8 *weights, Q_UINT32 nColors, Q_UINT8 *dst) const +{ + Q_UINT8 totalY = 0, totalCb = 0, totalCr = 0, newAlpha = 0; + + while (nColors--) + { + const Pixel *pixel = reinterpret_cast<const Pixel *>(*colors); + + Q_UINT8 alpha = pixel->alpha; + float alphaTimesWeight = alpha * *weights; + + totalY += (Q_UINT8)(pixel->Y * alphaTimesWeight); + totalCb += (Q_UINT8)(pixel->Cb * alphaTimesWeight); + totalCr += (Q_UINT8)(pixel->Cr * alphaTimesWeight); + newAlpha += (Q_UINT8)(alphaTimesWeight); + + weights++; + colors++; + } + + Pixel *dstPixel = reinterpret_cast<Pixel *>(dst); + + dstPixel->alpha = newAlpha; + + if (newAlpha > 0) { + totalY = totalY / newAlpha; + totalCb = totalCb / newAlpha; + totalCr = totalCr / newAlpha; + } + + dstPixel->Y = totalY; + dstPixel->Cb = totalCb; + dstPixel->Cr = totalCr; +} + +QValueVector<KisChannelInfo *> KisYCbCrU8ColorSpace::channels() const { + return m_channels; +} + +Q_UINT32 KisYCbCrU8ColorSpace::nChannels() const { + return MAX_CHANNEL_YCbCrA; +} + +Q_UINT32 KisYCbCrU8ColorSpace::nColorChannels() const { + return MAX_CHANNEL_YCbCr; +} + +Q_UINT32 KisYCbCrU8ColorSpace::pixelSize() const { + return MAX_CHANNEL_YCbCrA*sizeof(Q_UINT8); +} + + +QImage KisYCbCrU8ColorSpace::convertToQImage(const Q_UINT8 *data, Q_INT32 width, Q_INT32 height, KisProfile * dstProfile, Q_INT32 renderingIntent, float exposure ) +{ + if(getProfile()) + return KisU8BaseColorSpace::convertToQImage( data, width, height, dstProfile, renderingIntent, exposure); + + QImage img = QImage(width, height, 32, 0, QImage::LittleEndian); + img.setAlphaBuffer(true); + + Q_INT32 i = 0; + uchar *j = img.bits(); + + while ( i < width * height * MAX_CHANNEL_YCbCrA) { + Q_UINT8 Y = *( data + i + PIXEL_Y ); + Q_UINT8 Cb = *( data + i + PIXEL_Cb ); + Q_UINT8 Cr = *( data + i + PIXEL_Cr ); + *( j + 3) = *( data + i + PIXEL_ALPHA ); + *( j + 2 ) = computeRed(Y,Cb,Cr); + *( j + 1 ) = computeGreen(Y,Cb,Cr); + *( j + 0 ) = computeBlue(Y,Cb,Cr); + i += MAX_CHANNEL_YCbCrA; + j += 4; + } + return img; +} + + +void KisYCbCrU8ColorSpace::bitBlt(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *srcAlphaMask, Q_INT32 maskRowStride, Q_UINT8 opacity, Q_INT32 rows, Q_INT32 cols, const KisCompositeOp& op) +{ + switch (op.op()) { + case COMPOSITE_UNDEF: + // Undefined == no composition + break; + case COMPOSITE_OVER: + compositeOver(dst, dstRowStride, src, srcRowStride, srcAlphaMask, maskRowStride, rows, cols, opacity); + break; + case COMPOSITE_COPY: + compositeCopy(dst, dstRowStride, src, srcRowStride, srcAlphaMask, maskRowStride, rows, cols, opacity); + break; + case COMPOSITE_ERASE: + compositeErase(dst, dstRowStride, src, srcRowStride, srcAlphaMask, maskRowStride, rows, cols, opacity); + break; + default: + break; + } +} + +void KisYCbCrU8ColorSpace::compositeOver(Q_UINT8 *dstRowStart, Q_INT32 dstRowStride, const Q_UINT8 *srcRowStart, Q_INT32 srcRowStride, const Q_UINT8 *maskRowStart, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 numColumns, Q_UINT8 opacity) +{ + while (rows > 0) { + + const Q_UINT8 *src = srcRowStart; + Q_UINT8 *dst = dstRowStart; + const Q_UINT8 *mask = maskRowStart; + Q_INT32 columns = numColumns; + + while (columns > 0) { + + Q_UINT8 srcAlpha = src[PIXEL_ALPHA]; + + // apply the alphamask + if (mask != 0) { + if (*mask != OPACITY_OPAQUE) { + srcAlpha *= *mask; + } + mask++; + } + + if (srcAlpha > OPACITY_TRANSPARENT) { + + if (opacity < OPACITY_OPAQUE) { + srcAlpha *= opacity; + } + + if (srcAlpha == OPACITY_OPAQUE) { + memcpy(dst, src, MAX_CHANNEL_YCbCrA * sizeof(Q_UINT8)); + } else { + Q_UINT8 dstAlpha = dst[PIXEL_ALPHA]; + + Q_UINT8 srcBlend; + + if (dstAlpha == OPACITY_OPAQUE ) { + srcBlend = srcAlpha; + } else { + Q_UINT8 newAlpha = dstAlpha + (OPACITY_OPAQUE - dstAlpha) * srcAlpha; + dst[PIXEL_ALPHA] = newAlpha; + + if (newAlpha > 0) { + srcBlend = srcAlpha / newAlpha; + } else { + srcBlend = srcAlpha; + } + } + + if (srcBlend == OPACITY_OPAQUE) { + memcpy(dst, src, MAX_CHANNEL_YCbCr * sizeof(Q_UINT8)); + } else { + dst[PIXEL_Y] = UINT8_BLEND(src[PIXEL_Y], dst[PIXEL_Y], srcBlend); + dst[PIXEL_Cb] = UINT8_BLEND(src[PIXEL_Cb], dst[PIXEL_Cb], srcBlend); + dst[PIXEL_Cr] = UINT8_BLEND(src[PIXEL_Cr], dst[PIXEL_Cr], srcBlend); + } + } + } + + columns--; + src += MAX_CHANNEL_YCbCrA; + dst += MAX_CHANNEL_YCbCrA; + } + + rows--; + srcRowStart += srcRowStride; + dstRowStart += dstRowStride; + if(maskRowStart) { + maskRowStart += maskRowStride; + } + } +} + +void KisYCbCrU8ColorSpace::compositeErase(Q_UINT8 *dst, Q_INT32 dstRowSize, const Q_UINT8 *src, Q_INT32 srcRowSize, const Q_UINT8 *srcAlphaMask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 cols, Q_UINT8 /*opacity*/) +{ + while (rows-- > 0) + { + const Pixel *s = reinterpret_cast<const Pixel *>(src); + Pixel *d = reinterpret_cast<Pixel *>(dst); + const Q_UINT8 *mask = srcAlphaMask; + + for (Q_INT32 i = cols; i > 0; i--, s++, d++) + { + Q_UINT8 srcAlpha = s -> alpha; + + // apply the alphamask + if (mask != 0) { + if (*mask != OPACITY_OPAQUE) { + srcAlpha = *mask; + } + mask++; + } + d -> alpha = srcAlpha * d -> alpha; + } + + dst += dstRowSize; + src += srcRowSize; + if(srcAlphaMask) { + srcAlphaMask += maskRowStride; + } + } +} + +void KisYCbCrU8ColorSpace::compositeCopy(Q_UINT8 *dstRowStart, Q_INT32 dstRowStride, const Q_UINT8 *srcRowStart, Q_INT32 srcRowStride, const Q_UINT8 */*mask*/, Q_INT32 /*maskRowStride*/, Q_INT32 rows, Q_INT32 numColumns, Q_UINT8 /*opacity*/) +{ + while (rows > 0) { + memcpy(dstRowStart, srcRowStart, numColumns * sizeof(Pixel)); + --rows; + srcRowStart += srcRowStride; + dstRowStart += dstRowStride; + } +} + +KisCompositeOpList KisYCbCrU8ColorSpace::userVisiblecompositeOps() const +{ + KisCompositeOpList list; + + list.append(KisCompositeOp(COMPOSITE_OVER)); + return list; +} diff --git a/krita/colorspaces/ycbcr_u8/kis_ycbcr_u8_colorspace.h b/krita/colorspaces/ycbcr_u8/kis_ycbcr_u8_colorspace.h new file mode 100644 index 00000000..bc4d8329 --- /dev/null +++ b/krita/colorspaces/ycbcr_u8/kis_ycbcr_u8_colorspace.h @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2006 Cyrille Berger <[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_YCBCR_U8_COLORSPACE_H +#define KIS_YCBCR_U8_COLORSPACE_H + +#include <kis_u8_base_colorspace.h> + +#include <klocale.h> + +#define LUMA_RED 0.2989 +#define LUMA_GREEN 0.587 +#define LUMA_BLUE 0.114 + +class KisYCbCrU8ColorSpace : public KisU8BaseColorSpace +{ + public: + KisYCbCrU8ColorSpace(KisColorSpaceFactoryRegistry* parent, KisProfile* p); + ~KisYCbCrU8ColorSpace(); + virtual bool willDegrade(ColorSpaceIndependence ) + { + return false; + }; + public: + void setPixel(Q_UINT8 *pixel, Q_UINT8 Y, Q_UINT8 Cb, Q_UINT8 Cr, Q_UINT8 alpha) const; + void getPixel(const Q_UINT8 *pixel, Q_UINT8 *Y, Q_UINT8 *Cb, Q_UINT8 *Cr, Q_UINT8 *alpha) const; + + virtual void fromQColor(const QColor& c, Q_UINT8 *dst, KisProfile * profile = 0); + virtual void fromQColor(const QColor& c, Q_UINT8 opacity, Q_UINT8 *dst, KisProfile * profile = 0); + + virtual void toQColor(const Q_UINT8 *src, QColor *c, KisProfile * profile = 0); + virtual void toQColor(const Q_UINT8 *src, QColor *c, Q_UINT8 *opacity, KisProfile * profile = 0); + + virtual Q_UINT8 difference(const Q_UINT8 *src1, const Q_UINT8 *src2); + virtual void mixColors(const Q_UINT8 **colors, const Q_UINT8 *weights, Q_UINT32 nColors, Q_UINT8 *dst) const; + + virtual QValueVector<KisChannelInfo *> channels() const; + virtual Q_UINT32 nChannels() const; + virtual Q_UINT32 nColorChannels() const; + virtual Q_UINT32 pixelSize() const; + + virtual QImage convertToQImage(const Q_UINT8 *data, Q_INT32 width, Q_INT32 height, + KisProfile * dstProfile, + Q_INT32 renderingIntent, + float exposure = 0.0f); + + virtual KisCompositeOpList userVisiblecompositeOps() const; + + protected: + + virtual void bitBlt(Q_UINT8 *dst, + Q_INT32 dstRowStride, + const Q_UINT8 *src, + Q_INT32 srcRowStride, + const Q_UINT8 *srcAlphaMask, + Q_INT32 maskRowStride, + Q_UINT8 opacity, + Q_INT32 rows, + Q_INT32 cols, + const KisCompositeOp& op); + + void compositeOver(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *mask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 columns, Q_UINT8 opacity); + void compositeErase(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *mask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 columns, Q_UINT8 opacity); + void compositeCopy(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *mask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 columns, Q_UINT8 opacity); + + private: +#define CLAMP_TO_8BITCHANNEL(a) CLAMP(a, 0, Q_UINT8_MAX) + inline Q_UINT8 computeRed(Q_UINT8 Y, Q_UINT8 /*Cb*/, Q_UINT8 Cr) + { + return (Q_UINT8)( CLAMP_TO_8BITCHANNEL( (Cr - 128)* (2-2*LUMA_RED) + Y ) ); + } + inline Q_UINT8 computeGreen(Q_UINT8 Y, Q_UINT8 Cb, Q_UINT8 Cr) + { + return (Q_UINT8)( CLAMP_TO_8BITCHANNEL( (Y - LUMA_BLUE * computeBlue(Y,Cb,Cr) - LUMA_RED * computeRed(Y,Cb,Cr) ) / LUMA_GREEN ) ); + } + inline Q_UINT8 computeBlue(Q_UINT8 Y, Q_UINT8 Cb, Q_UINT8 /*Cr*/) + { + return (Q_UINT8)( CLAMP_TO_8BITCHANNEL( (Cb - 128)*(2 - 2 * LUMA_BLUE) + Y) ); + } + inline Q_UINT8 computeY( Q_UINT8 r, Q_UINT8 b, Q_UINT8 g) + { + return (Q_UINT8)( CLAMP_TO_8BITCHANNEL( LUMA_RED*r + LUMA_GREEN*g + LUMA_BLUE*b ) ); + } + inline Q_UINT8 computeCb( Q_UINT8 r, Q_UINT8 b, Q_UINT8 g) + { + return (Q_UINT8)( CLAMP_TO_8BITCHANNEL( (b - computeY(r,g,b))/(2-2*LUMA_BLUE) + 128) ); + } + inline Q_UINT8 computeCr( Q_UINT8 r, Q_UINT8 b, Q_UINT8 g) + { + return (Q_UINT8)( CLAMP_TO_8BITCHANNEL( (r - computeY(r,g,b))/(2-2*LUMA_RED) + 128) ); + } +#undef CLAMP_TO_8BITCHANNEL + + static const Q_UINT8 PIXEL_Y = 0; + static const Q_UINT8 PIXEL_Cb = 1; + static const Q_UINT8 PIXEL_Cr = 2; + static const Q_UINT8 PIXEL_ALPHA = 3; + + struct Pixel { + Q_UINT8 Y; + Q_UINT8 Cb; + Q_UINT8 Cr; + Q_UINT8 alpha; + }; +}; + +class KisYCbCrU8ColorSpaceFactory : public KisColorSpaceFactory +{ + public: + /** + * Krita definition for use in .kra files and internally: unchanging name + + * i18n'able description. + */ + virtual KisID id() const { return KisID("YCbCrAU8", i18n("YCbCr (8-bit integer/channel)")); }; + + /** + * lcms colorspace type definition. + */ + virtual Q_UINT32 colorSpaceType() { return TYPE_YCbCr_8; }; + + virtual icColorSpaceSignature colorSpaceSignature() { return icSigYCbCrData; }; + + virtual KisColorSpace *createColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p) { return new KisYCbCrU8ColorSpace(parent, p); }; + + virtual QString defaultProfile() { return ""; }; +}; + +#endif diff --git a/krita/colorspaces/ycbcr_u8/krita_ycbcr_u8_plugin.desktop b/krita/colorspaces/ycbcr_u8/krita_ycbcr_u8_plugin.desktop new file mode 100644 index 00000000..2c29e972 --- /dev/null +++ b/krita/colorspaces/ycbcr_u8/krita_ycbcr_u8_plugin.desktop @@ -0,0 +1,71 @@ +[Desktop Entry] +Name=YCbCr Color Model (8-bit integer) +Name[bg]=Цветови модел YCbCr (16 бита) +Name[ca]=Model de color YCbCr (enters de 16 bits) +Name[da]=YCbCr-farvemodel (8-bit heltal) +Name[de]=YCbCr-Farbmodell (8-bit Ganzzahl) +Name[el]=Χρωματικό μοντέλο YCbCr (16-bit ακέραιοι) +Name[eo]=YCbCr-Kolormodelo (8-bita entjero) +Name[es]=Modelo de color YCbCr (entero de 8 bits) +Name[et]=YCbCr värvimudel (8-bitine täisarv) +Name[fa]=مدل رنگ YCbCr )عدد صحیح ۸ بیتی( +Name[fr]=Modèle de couleurs YCbCr (entiers 8 bits) +Name[fy]=YCbCr-kleurmodel (8-bit integer) +Name[gl]=Modelo de Cores YCbCr (inteiro de 8-bit) +Name[hu]=YCbCr színmodell (8 bites egész) +Name[it]=Modello di colore YCbCr (intero a 8 bit) +Name[ja]=YCbCr カラーモデル (8 ビット整数) +Name[km]=គំរូពណ៌ CMYK (ចំនួនគត់ ១៦ ប៊ីត) +Name[lt]=YCbCr spalvų modelis (8-bitų sveikasis) +Name[nb]=YCbCr fargemodell (8-bit heltall) +Name[nds]=YCbCr-Klöörmodell (8-Bit Heeltall) +Name[ne]=वाईसीबीसीआर रङ मोडेल (८-बिट इन्टिजर) +Name[nl]=YCbCr-kleurmodel (8-bit integer) +Name[pl]=Przestrzeń barw YCbCr (8-bitowa liczbowa całkowita) +Name[pt]=Modelo de Cor YCbCr (inteiros de 8 bits) +Name[pt_BR]=Modelo de Cor YCbCr (inteiros de 8 bits) +Name[ru]=YCbCr (целое 8-бит) +Name[sk]=Model farieb YCbCr (8-biové čísla) +Name[sl]=Barvni model YCbCr (8-bitno celo število) +Name[sr]=YCbCr модел боја (8-битно целобројно) +Name[sr@Latn]=YCbCr model boja (8-bitno celobrojno) +Name[sv]=YCbCr-färgmodell (8-bitars heltal) +Name[uk]=Модель кольорів YCbCr (ціле 8-біт) +Name[uz]=YCbCr rang usuli (8-bit butun) +Name[uz@cyrillic]=YCbCr ранг усули (8-бит бутун) +Name[zh_TW]=YCbCr 色彩模型 (16-bit 整數) +Comment=Color model for 8-bit integer per channel YCbCr images +Comment[bg]=Цветови модел за 16 битови YCbCr изображения +Comment[ca]=Model de color d'enters de 16 bits per a canal d'imatges YCbCr +Comment[da]=Farvemodel for 8-bit heltal pr kanal YCbCr-billeder +Comment[de]=Farbmodell für 8-bit pro Kanal YCbCr-Bilder +Comment[el]=Χρωματικό μοντέλο για 8-bit ακεραίους ανά κανάλι YCbCr εικόνες +Comment[es]=Modelo de color de entero de 16 bits por canal para imágenes YCbCr +Comment[et]=8-bitiste täisarvuliste kanalitega YCbCr-piltide värvimudel +Comment[fa]=مدل رنگ برای عدد صحیح ۸ بیتی برای هر تصویر YCbCr مجرا +Comment[fr]=Modèle de couleurs pour des images YCbCr à 8 bits par canal +Comment[fy]=Kleurmodel foar 8-bit/kanaal fan YCbCr-ôfbyldings +Comment[gl]=Modelo de Cores para imaxes YCbCr de inteiro de 8-bit por canal +Comment[hu]=Színmodell 8 bit/csatorna YCbCr képekhez +Comment[it]=Modello di colore per immagini YCbCr a canale di 8 bit interi +Comment[ja]=8 ビット整数/チャンネル YCbCr 画像のためのカラーモデル +Comment[km]=ម៉ូដែលពណ៌សម្រាប់ចំនួនគត់ 8-bit ក្នុងឆានែលរូបភាព YCbCr +Comment[nb]=Fargemodell for YCbCr-bilder med 8 bit heltall per kanal +Comment[nds]=Klöörmodell för YCbCr-Biller mit 8-Bit Heeltall pro Kanaal +Comment[ne]=प्रति वाईसीबीसीआर छविहरूको ८-बिट इन्टिजरका लागि रङ मोडेल +Comment[nl]=Kleurmodel voor 8-bit/kanaal van YCbCr-afbeeldingen +Comment[pl]=Przestrzeń barw dla obrazków YCbCr z 8-bitowymi liczbami całkowitymi na kanał +Comment[pt]=Modelo de cor para imagens YCbCr com 8 bits por canal +Comment[pt_BR]=Modelo de cor para imagens YCbCr com 8 bits por canal +Comment[ru]=Цветовое пространство YCbCr (целое 8-бит/канал) +Comment[sk]=Model farieb pre YCbCr obrázky s 8 bitmi na kanál +Comment[sl]=Barvni model za slike YCbCr z 8 biti/kanal +Comment[sr]=Модел боја за YCbCr слике, 8-битно целобројно по каналу +Comment[sr@Latn]=Model boja za YCbCr slike, 8-bitno celobrojno po kanalu +Comment[sv]=Färgmodell för YCbCr-bilder med 8-bitars heltal per kanal +Comment[uk]=Модель кольорів для зображень YCbCr з цілим 8-біт/канал +Comment[zh_TW]=每色頻為 16-bit 的 YCbCr 圖片色彩模型 +ServiceTypes=Krita/ColorSpace +Type=Service +X-KDE-Library=krita_ycbcr_u8_plugin +X-Krita-Version=2 diff --git a/krita/colorspaces/ycbcr_u8/ycbcr_u8_plugin.cc b/krita/colorspaces/ycbcr_u8/ycbcr_u8_plugin.cc new file mode 100644 index 00000000..751e3f31 --- /dev/null +++ b/krita/colorspaces/ycbcr_u8/ycbcr_u8_plugin.cc @@ -0,0 +1,62 @@ +/* + * ycbcr_u8_plugin.cc -- Part of Krita + * + * Copyright (c) 2006 Cyrille Berger <[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 "ycbcr_u8_plugin.h" + +#include <kinstance.h> +#include <kgenericfactory.h> +#include <kdebug.h> + +#include <kis_debug_areas.h> +#include <kis_colorspace_factory_registry.h> +#include <kis_basic_histogram_producers.h> +#include <kis_debug_areas.h> + +#include "kis_ycbcr_u8_colorspace.h" + +typedef KGenericFactory<YCbCrU8Plugin> YCbCrU8PluginFactory; +K_EXPORT_COMPONENT_FACTORY( krita_ycbcr_u8_plugin, YCbCrU8PluginFactory( "krita" ) ) + + +YCbCrU8Plugin::YCbCrU8Plugin(QObject *parent, const char *name, const QStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(YCbCrU8PluginFactory::instance()); + + if ( parent->inherits("KisColorSpaceFactoryRegistry") ) + { + KisColorSpaceFactoryRegistry * f = dynamic_cast<KisColorSpaceFactoryRegistry*>( parent ); + + KisColorSpace * colorSpaceYCbCrU8 = new KisYCbCrU8ColorSpace(f, 0); + KisColorSpaceFactory * csf = new KisYCbCrU8ColorSpaceFactory(); + Q_CHECK_PTR(colorSpaceYCbCrU8); + f->add(csf); + KisHistogramProducerFactoryRegistry::instance()->add( + new KisBasicHistogramProducerFactory<KisBasicU16HistogramProducer> + (KisID("YCBR8HISTO", i18n("YCBR8")), colorSpaceYCbCrU8) ); + } + +} + +YCbCrU8Plugin::~YCbCrU8Plugin() +{ +} + +#include "ycbcr_u8_plugin.moc" diff --git a/krita/colorspaces/ycbcr_u8/ycbcr_u8_plugin.h b/krita/colorspaces/ycbcr_u8/ycbcr_u8_plugin.h new file mode 100644 index 00000000..ef418784 --- /dev/null +++ b/krita/colorspaces/ycbcr_u8/ycbcr_u8_plugin.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2006 Cyrille Berger <[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 YCBCR_U8_PLUGIN_H_ +#define YCBCR_U8_PLUGIN_H_ + +#include <kparts/plugin.h> + +/** + * A plugin wrapper around the YCbCr U8 colour space strategy. + */ +class YCbCrU8Plugin : public KParts::Plugin +{ + Q_OBJECT +public: + YCbCrU8Plugin(QObject *parent, const char *name, const QStringList &); + virtual ~YCbCrU8Plugin(); + +}; + + +#endif // YCBCR_U8_PLUGIN_H_ |