[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-kimageshop
Subject: Re: https://bugs.kde.org/show_bug.cgi?id=281761 -- scaling between
From: Boudewijn Rempt <boud () valdyas ! org>
Date: 2011-09-18 13:49:14
Message-ID: 201109181549.14779.boud () valdyas ! org
[Download RAW message or body]
On Sunday 18 September 2011 Sep, Silvio Heinrich wrote:
> On 09/18/2011 03:06 PM, Boudewijn Rempt wrote:
> > hi,
> >
> > I'm stuck with this bug... Could someone with adequate templating foo please \
> > check my patch and help me out a bit? I get a crash now if I follow the \
> > instructions in the bug report exactly.
> could you send the patch to the mailing list?
> I can't apply the patch from the bug tracker.
Sure, here it is.
--
Boudewijn Rempt
http://www.valdyas.org, http://www.krita.org, http://www.boudewijnrempt.nl
["cmyk16to8.diff" (text/x-patch)]
diff --git a/libs/pigment/KoColorSpaceAbstract.h
b/libs/pigment/KoColorSpaceAbstract.h
index fb5d56b..6a1a285 100644
--- a/libs/pigment/KoColorSpaceAbstract.h
+++ b/libs/pigment/KoColorSpaceAbstract.h
@@ -25,6 +25,7 @@
#include <klocale.h>
#include <KoColorSpace.h>
+#include <KoColorProfile.h>
#include "KoColorSpaceConstants.h"
#include <KoColorSpaceMaths.h>
#include <KoColorSpaceRegistry.h>
@@ -100,6 +101,7 @@ public:
typename _CSTrait::channels_type c = \
_CSTrait::nativeArray(srcPixel)[channelIndex];
return KoColorSpaceMaths<typename _CSTrait::channels_type, \
quint16>::scaleToA(c); }
+
virtual void singleChannelPixel(quint8 *dstPixel, const quint8 *srcPixel, \
quint32 channelIndex) const { _CSTrait::singleChannelPixel(dstPixel, srcPixel, \
channelIndex); }
@@ -149,7 +151,49 @@ public:
virtual KoID mathToolboxId() const {
return KoID("Basic");
}
-};
+ // Scale the specified channel from the source pixel to T and copy it into the \
destination pixel. + // the template parameter is the type of the source channel
+ template<typename T>
+ void scaleTo(const quint8 *srcPixel, quint8 *dstPixel, qint32 srcChannelIndex, \
qint32 dstChannelIndex) const { + T srcChannel = \
_CSTrait::nativeArray(srcPixel)[srcChannelIndex]; + typename \
_CSTrait::channels_type dstChannel = KoColorSpaceMaths<typename \
_CSTrait::channels_type, T>::scaleToA(srcChannel); + memcpy(dstPixel + \
(dstChannelIndex * sizeof(srcChannel)), &dstChannel, sizeof(dstChannel)); + }
+
+ virtual bool convertPixelsTo(const quint8 *src,
+ quint8 *dst, const KoColorSpace *dstColorSpace,
+ quint32 numPixels,
+ KoColorConversionTransformation::Intent \
renderingIntent = KoColorConversionTransformation::IntentPerceptual) const { +
+
+
+ // check whether we have the same profile and color model, but only a \
different bit + // depth; in that case we don't convert as such, but scale
+ bool scaleOnly = dstColorSpace->colorModelId().id() == colorModelId().id()
+ && dstColorSpace->colorDepthId().id() != colorDepthId().id()
+ && dstColorSpace->profile()->name() == profile()->name();
+
+ const KoColorSpaceAbstract *cs = static_cast<const \
KoColorSpaceAbstract*>(dstColorSpace); +
+ if (scaleOnly && cs) {
+
+ // Use KoColorSpaceMaths and KoColorSpaceTraits to create the right \
scaling maths + // object and just scale the pixels.
+ int numberOfChannels = channelCount();
+ for (uint pixel = 0; pixel < numPixels; ++pixel) {
+ for (int channel = 0; channel < numberOfChannels; ++channel) {
+ cs->scaleTo<typename _CSTrait::channels_type >(src + (pixel * \
pixelSize()), dst + (pixel * pixelSize()), channel, channel); + }
+ }
+ return true;
+ }
+ else {
+ return KoColorSpace::convertPixelsTo(src, dst, dstColorSpace, numPixels, \
renderingIntent); + }
+
+ return false;
+ }
+};
#endif
_______________________________________________
kimageshop mailing list
kimageshop@kde.org
https://mail.kde.org/mailman/listinfo/kimageshop
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic