Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Miguel Lopez
Krita
Commits
7ce9a273
Commit
7ce9a273
authored
Jan 16, 2010
by
Cyrille Berger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restyle
svn path=/trunk/koffice/; revision=1075503
parent
68a0dc53
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
73 additions
and
90 deletions
+73
-90
libs/pigment/KoColorConversions.cpp
libs/pigment/KoColorConversions.cpp
+1
-1
libs/pigment/KoColorSpaceMaths.h
libs/pigment/KoColorSpaceMaths.h
+6
-6
libs/pigment/KoColorSpaceRegistry.cpp
libs/pigment/KoColorSpaceRegistry.cpp
+2
-3
libs/pigment/KoColorSpaceTraits.h
libs/pigment/KoColorSpaceTraits.h
+2
-2
libs/pigment/KoConvolutionOp.h
libs/pigment/KoConvolutionOp.h
+1
-1
libs/pigment/KoConvolutionOpImpl.h
libs/pigment/KoConvolutionOpImpl.h
+1
-1
libs/pigment/KoHistogramProducer.h
libs/pigment/KoHistogramProducer.h
+1
-1
libs/pigment/KoMixColorsOp.h
libs/pigment/KoMixColorsOp.h
+1
-1
libs/pigment/KoScaleColorConversionTransformation.h
libs/pigment/KoScaleColorConversionTransformation.h
+1
-1
libs/pigment/colorspaces/KoLabColorSpace.cpp
libs/pigment/colorspaces/KoLabColorSpace.cpp
+25
-27
libs/pigment/colorspaces/KoSimpleColorSpace.h
libs/pigment/colorspaces/KoSimpleColorSpace.h
+10
-19
libs/pigment/colorspaces/KoSimpleColorSpaceEngine.cpp
libs/pigment/colorspaces/KoSimpleColorSpaceEngine.cpp
+3
-5
libs/pigment/resources/KoSegmentGradient.cpp
libs/pigment/resources/KoSegmentGradient.cpp
+15
-18
libs/pigment/tests/TestKoColor.cpp
libs/pigment/tests/TestKoColor.cpp
+1
-1
libs/pigment/tests/TestKoIntegerMaths.cpp
libs/pigment/tests/TestKoIntegerMaths.cpp
+3
-3
No files found.
libs/pigment/KoColorConversions.cpp
View file @
7ce9a273
...
...
@@ -297,7 +297,7 @@ float hue_value(float n1, float n2, float hue)
else
if
(
hue
<
180
)
return
n2
;
else
if
(
hue
<
240
)
return
n1
+
(((
n2
-
n1
)
*
(
240
-
hue
))
/
60
);
return
n1
+
(((
n2
-
n1
)
*
(
240
-
hue
))
/
60
);
else
return
n1
;
}
...
...
libs/pigment/KoColorSpaceMaths.h
View file @
7ce9a273
...
...
@@ -216,7 +216,7 @@ inline quint8 KoColorSpaceMaths<double, quint8>::scaleToA(double a)
template
<
>
inline
double
KoColorSpaceMaths
<
quint8
,
double
>::
scaleToA
(
quint8
a
)
{
return
a
*
(
1.0
/
255.0
);
return
a
*
(
1.0
/
255.0
);
}
template
<
>
...
...
@@ -229,7 +229,7 @@ inline quint16 KoColorSpaceMaths<double, quint16>::scaleToA(double a)
template
<
>
inline
double
KoColorSpaceMaths
<
quint16
,
double
>::
scaleToA
(
quint16
a
)
{
return
a
*
(
1.0
/
0xFFFF
);
return
a
*
(
1.0
/
0xFFFF
);
}
template
<
>
...
...
@@ -262,7 +262,7 @@ inline quint16 KoColorSpaceMaths<float, quint16>::scaleToA(float a)
template
<
>
inline
float
KoColorSpaceMaths
<
quint16
,
float
>::
scaleToA
(
quint16
a
)
{
return
a
*
(
1.0
/
0xFFFF
);
return
a
*
(
1.0
/
0xFFFF
);
}
template
<
>
...
...
@@ -275,7 +275,7 @@ inline quint8 KoColorSpaceMaths<float, quint8>::scaleToA(float a)
template
<
>
inline
float
KoColorSpaceMaths
<
quint8
,
float
>::
scaleToA
(
quint8
a
)
{
return
a
*
(
1.0
/
255.0
);
return
a
*
(
1.0
/
255.0
);
}
template
<
>
...
...
@@ -328,7 +328,7 @@ inline quint8 KoColorSpaceMaths<half, quint8>::scaleToA(half a)
template
<
>
inline
half
KoColorSpaceMaths
<
quint8
,
half
>::
scaleToA
(
quint8
a
)
{
return
a
*
(
1.0
/
255.0
);
return
a
*
(
1.0
/
255.0
);
}
template
<
>
inline
quint16
KoColorSpaceMaths
<
half
,
quint16
>::
scaleToA
(
half
a
)
...
...
@@ -340,7 +340,7 @@ inline quint16 KoColorSpaceMaths<half, quint16>::scaleToA(half a)
template
<
>
inline
half
KoColorSpaceMaths
<
quint16
,
half
>::
scaleToA
(
quint16
a
)
{
return
a
*
(
1.0
/
0xFFFF
);
return
a
*
(
1.0
/
0xFFFF
);
}
template
<
>
...
...
libs/pigment/KoColorSpaceRegistry.cpp
View file @
7ce9a273
...
...
@@ -282,8 +282,7 @@ const KoColorSpace * KoColorSpaceRegistry::colorSpace(const QString &csID, const
if
(
profiles
.
isEmpty
())
{
dbgPigmentCSRegistry
<<
"No profile at all available for "
<<
csf
;
p
=
0
;
}
else
{
}
else
{
p
=
profiles
[
0
];
Q_ASSERT
(
p
);
}
...
...
@@ -480,7 +479,7 @@ const KoColorSpace* KoColorSpaceRegistry::permanentColorspace(const KoColorSpace
QList
<
KoID
>
KoColorSpaceRegistry
::
listKeys
()
const
{
QList
<
KoID
>
answer
;
foreach
(
const
QString
key
,
keys
())
{
foreach
(
const
QString
key
,
keys
())
{
answer
.
append
(
KoID
(
key
,
get
(
key
)
->
name
()));
}
...
...
libs/pigment/KoColorSpaceTraits.h
View file @
7ce9a273
...
...
@@ -93,7 +93,7 @@ struct KoColorSpaceTrait {
inline
static
void
singleChannelPixel
(
quint8
*
dstPixel
,
const
quint8
*
srcPixel
,
quint32
channelIndex
)
{
const
channels_type
*
src
=
nativeArray
(
srcPixel
);
channels_type
*
dst
=
nativeArray
(
dstPixel
);
for
(
uint
i
=
0
;
i
<
channels_nb
;
i
++
)
{
for
(
uint
i
=
0
;
i
<
channels_nb
;
i
++
)
{
if
(
i
!=
channelIndex
)
{
dst
[
i
]
=
0
;
}
else
{
...
...
@@ -110,7 +110,7 @@ struct KoColorSpaceTrait {
inline
static
QString
normalisedChannelValueText
(
const
quint8
*
pixel
,
quint32
channelIndex
)
{
if
(
channelIndex
>
channels_nb
)
return
QString
(
"Error"
);
channels_type
c
=
nativeArray
(
pixel
)[
channelIndex
];
return
QString
().
setNum
(
100.
*
((
qreal
)
c
)
/
KoColorSpaceMathsTraits
<
channels_type
>::
unitValue
);
return
QString
().
setNum
(
100.
*
((
qreal
)
c
)
/
KoColorSpaceMathsTraits
<
channels_type
>::
unitValue
);
}
inline
static
void
normalisedChannelsValue
(
const
quint8
*
pixel
,
QVector
<
float
>
&
channels
)
{
...
...
libs/pigment/KoConvolutionOp.h
View file @
7ce9a273
...
...
@@ -50,4 +50,4 @@ public:
virtual
void
convolveColors
(
const
quint8
*
const
*
colors
,
const
qreal
*
kernelValues
,
quint8
*
dst
,
qreal
factor
,
qreal
offset
,
qint32
nColors
,
const
QBitArray
&
channelFlags
)
const
=
0
;
};
#endif
#endif
libs/pigment/KoConvolutionOpImpl.h
View file @
7ce9a273
...
...
@@ -83,7 +83,7 @@ public:
memset
(
totals
,
0
,
sizeof
(
qreal
)
*
_CSTrait
::
channels_nb
);
for
(;
nPixels
--
;
colors
++
,
kernelValues
++
)
{
for
(;
nPixels
--
;
colors
++
,
kernelValues
++
)
{
qreal
weight
=
*
kernelValues
;
const
channels_type
*
color
=
_CSTrait
::
nativeArray
(
*
colors
);
if
(
weight
!=
0
)
{
...
...
libs/pigment/KoHistogramProducer.h
View file @
7ce9a273
...
...
@@ -123,7 +123,7 @@ protected:
};
class
PIGMENTCMS_EXPORT
KoHistogramProducerFactoryRegistry
:
public
KoGenericRegistry
<
KoHistogramProducerFactory
*>
:
public
KoGenericRegistry
<
KoHistogramProducerFactory
*>
{
public:
virtual
~
KoHistogramProducerFactoryRegistry
();
...
...
libs/pigment/KoMixColorsOp.h
View file @
7ce9a273
...
...
@@ -41,4 +41,4 @@ public:
virtual
void
mixColors
(
const
quint8
*
const
*
colors
,
const
qint16
*
weights
,
quint32
nColors
,
quint8
*
dst
)
const
=
0
;
};
#endif
#endif
libs/pigment/KoScaleColorConversionTransformation.h
View file @
7ce9a273
...
...
@@ -35,7 +35,7 @@ public:
virtual
void
transform
(
const
quint8
*
srcU8
,
quint8
*
dstU8
,
qint32
nPixels
)
const
{
const
typename
_src_CSTraits_
::
channels_type
*
src
=
_src_CSTraits_
::
nativeArray
(
srcU8
);
typename
_dst_CSTraits_
::
channels_type
*
dst
=
_dst_CSTraits_
::
nativeArray
(
dstU8
);
for
(
quint32
i
=
0
;
i
<
_src_CSTraits_
::
channels_nb
*
nPixels
;
i
++
)
{
for
(
quint32
i
=
0
;
i
<
_src_CSTraits_
::
channels_nb
*
nPixels
;
i
++
)
{
dst
[
i
]
=
KoColorSpaceMaths
<
typename
_src_CSTraits_
::
channels_type
,
typename
_dst_CSTraits_
::
channels_type
>::
scaleToA
(
src
[
i
]);
}
}
...
...
libs/pigment/colorspaces/KoLabColorSpace.cpp
View file @
7ce9a273
...
...
@@ -60,7 +60,8 @@ KoLabColorSpace::~KoLabColorSpace()
}
QString
KoLabColorSpace
::
colorSpaceId
(){
QString
KoLabColorSpace
::
colorSpaceId
()
{
return
QString
(
"LABA"
);
}
...
...
@@ -91,26 +92,23 @@ void KoLabColorSpace::fromQColor(const QColor& c, quint8 *dst, const KoColorProf
quint8
L
,
a
,
b
;
if
(
Y
>
0.008856
)
{
fY
=
pow
(
Y
,
1.0
/
3.0
);
L
=
static_cast
<
int
>
(
116.0
*
fY
-
16.0
+
0.5
);
}
else
{
fY
=
7.787
*
Y
+
16.0
/
116.0
;
L
=
static_cast
<
int
>
(
903.3
*
Y
+
0.5
);
if
(
Y
>
0.008856
)
{
fY
=
pow
(
Y
,
1.0
/
3.0
);
L
=
static_cast
<
int
>
(
116.0
*
fY
-
16.0
+
0.5
);
}
else
{
fY
=
7.787
*
Y
+
16.0
/
116.0
;
L
=
static_cast
<
int
>
(
903.3
*
Y
+
0.5
);
}
if
(
X
>
0.008856
)
fX
=
pow
(
X
,
1.0
/
3.0
);
if
(
X
>
0.008856
)
fX
=
pow
(
X
,
1.0
/
3.0
);
else
fX
=
7.787
*
X
+
16.0
/
116.0
;
fX
=
7.787
*
X
+
16.0
/
116.0
;
if
(
Z
>
0.008856
)
fZ
=
pow
(
Z
,
1.0
/
3.0
);
if
(
Z
>
0.008856
)
fZ
=
pow
(
Z
,
1.0
/
3.0
);
else
fZ
=
7.787
*
Z
+
16.0
/
116.0
;
fZ
=
7.787
*
Z
+
16.0
/
116.0
;
a
=
static_cast
<
int
>
(
500.0
*
(
fX
-
fY
)
+
0.5
);
b
=
static_cast
<
int
>
(
200.0
*
(
fY
-
fZ
)
+
0.5
);
...
...
@@ -136,26 +134,26 @@ void KoLabColorSpace::toQColor(const quint8 * src, QColor *c, const KoColorProfi
int
RR
,
GG
,
BB
;
fY
=
pow
((
L
+
16.0
)
/
116.0
,
3.0
);
if
(
fY
<
0.008856
)
fY
=
L
/
903.3
;
if
(
fY
<
0.008856
)
fY
=
L
/
903.3
;
Y
=
fY
;
if
(
fY
>
0.008856
)
fY
=
pow
(
fY
,
1.0
/
3.0
);
if
(
fY
>
0.008856
)
fY
=
pow
(
fY
,
1.0
/
3.0
);
else
fY
=
7.787
*
fY
+
16.0
/
116.0
;
fY
=
7.787
*
fY
+
16.0
/
116.0
;
fX
=
a
/
500.0
+
fY
;
if
(
fX
>
0.206893
)
X
=
pow
(
fX
,
3.0
);
if
(
fX
>
0.206893
)
X
=
pow
(
fX
,
3.0
);
else
X
=
(
fX
-
16.0
/
116.0
)
/
7.787
;
X
=
(
fX
-
16.0
/
116.0
)
/
7.787
;
fZ
=
fY
-
b
/
200.0
;
if
(
fZ
>
0.206893
)
Z
=
pow
(
fZ
,
3.0
);
if
(
fZ
>
0.206893
)
Z
=
pow
(
fZ
,
3.0
);
else
Z
=
(
fZ
-
16.0
/
116.0
)
/
7.787
;
Z
=
(
fZ
-
16.0
/
116.0
)
/
7.787
;
X
*=
0.950456
*
255
;
Y
*=
255
;
...
...
libs/pigment/colorspaces/KoSimpleColorSpace.h
View file @
7ce9a273
...
...
@@ -120,45 +120,37 @@ public:
warnPigment
<<
i18n
(
"Undefined operation in the %1 color space"
).
arg
(
m_name
);
}
virtual
void
toLabA16
(
const
quint8
*
src
,
quint8
*
dst
,
quint32
nPixels
)
const
{
virtual
void
toLabA16
(
const
quint8
*
src
,
quint8
*
dst
,
quint32
nPixels
)
const
{
if
(
colorDepthId
()
==
Integer16BitsColorDepthID
&&
colorModelId
()
==
LABAColorModelID
)
{
memcpy
(
dst
,
src
,
nPixels
*
2
);
}
else
{
}
else
{
const
KoColorSpace
*
dstCs
=
KoColorSpaceRegistry
::
instance
()
->
lab16
();
convertPixelsTo
(
src
,
dst
,
dstCs
,
nPixels
);
}
}
virtual
void
fromLabA16
(
const
quint8
*
src
,
quint8
*
dst
,
quint32
nPixels
)
const
{
virtual
void
fromLabA16
(
const
quint8
*
src
,
quint8
*
dst
,
quint32
nPixels
)
const
{
if
(
colorDepthId
()
==
Integer16BitsColorDepthID
&&
colorModelId
()
==
LABAColorModelID
)
{
memcpy
(
dst
,
src
,
nPixels
*
2
);
}
else
{
}
else
{
const
KoColorSpace
*
srcCs
=
KoColorSpaceRegistry
::
instance
()
->
lab16
();
srcCs
->
convertPixelsTo
(
src
,
dst
,
this
,
nPixels
);
}
}
virtual
void
toRgbA16
(
const
quint8
*
src
,
quint8
*
dst
,
quint32
nPixels
)
const
{
virtual
void
toRgbA16
(
const
quint8
*
src
,
quint8
*
dst
,
quint32
nPixels
)
const
{
if
(
colorDepthId
()
==
Integer16BitsColorDepthID
&&
colorModelId
()
==
RGBAColorModelID
)
{
memcpy
(
dst
,
src
,
nPixels
*
2
);
}
else
{
}
else
{
const
KoColorSpace
*
dstCs
=
KoColorSpaceRegistry
::
instance
()
->
rgb16
();
convertPixelsTo
(
src
,
dst
,
dstCs
,
nPixels
);
}
}
virtual
void
fromRgbA16
(
const
quint8
*
src
,
quint8
*
dst
,
quint32
nPixels
)
const
{
virtual
void
fromRgbA16
(
const
quint8
*
src
,
quint8
*
dst
,
quint32
nPixels
)
const
{
if
(
colorDepthId
()
==
Integer16BitsColorDepthID
&&
colorModelId
()
==
RGBAColorModelID
)
{
memcpy
(
dst
,
src
,
nPixels
*
2
);
}
else
{
}
else
{
const
KoColorSpace
*
srcCs
=
KoColorSpaceRegistry
::
instance
()
->
rgb16
();
srcCs
->
convertPixelsTo
(
src
,
dst
,
this
,
nPixels
);
}
...
...
@@ -167,15 +159,14 @@ public:
virtual
bool
convertPixelsTo
(
const
quint8
*
src
,
quint8
*
dst
,
const
KoColorSpace
*
dstColorSpace
,
quint32
numPixels
,
KoColorConversionTransformation
::
Intent
renderingIntent
=
KoColorConversionTransformation
::
IntentPerceptual
)
const
{
KoColorConversionTransformation
::
Intent
renderingIntent
=
KoColorConversionTransformation
::
IntentPerceptual
)
const
{
Q_UNUSED
(
renderingIntent
);
QColor
c
;
quint32
srcPixelsize
=
this
->
pixelSize
();
quint32
dstPixelsize
=
dstColorSpace
->
pixelSize
();
while
(
numPixels
>
0
)
{
while
(
numPixels
>
0
)
{
this
->
toQColor
(
src
,
&
c
);
dstColorSpace
->
fromQColor
(
c
,
dst
);
...
...
libs/pigment/colorspaces/KoSimpleColorSpaceEngine.cpp
View file @
7ce9a273
...
...
@@ -34,15 +34,13 @@ class KoSimpleColorConversionTransformation : public KoColorConversionTransforma
{
public:
KoSimpleColorConversionTransformation
(
const
KoColorSpace
*
srcCs
,
const
KoColorSpace
*
dstCs
)
:
KoColorConversionTransformation
(
srcCs
,
dstCs
)
{
:
KoColorConversionTransformation
(
srcCs
,
dstCs
)
{
}
~
KoSimpleColorConversionTransformation
()
{
}
virtual
void
transform
(
const
quint8
*
src
,
quint8
*
dst
,
qint32
numPixels
)
const
{
virtual
void
transform
(
const
quint8
*
src
,
quint8
*
dst
,
qint32
numPixels
)
const
{
const
KoColorSpace
*
srcCs
=
srcColorSpace
();
const
KoColorSpace
*
dstCs
=
dstColorSpace
();
...
...
@@ -67,7 +65,7 @@ public:
KoSimpleColorSpaceEngine
::
KoSimpleColorSpaceEngine
()
:
KoColorSpaceEngine
(
"simple"
,
i18n
(
"Simple Color Conversion Engine"
))
:
KoColorSpaceEngine
(
"simple"
,
i18n
(
"Simple Color Conversion Engine"
))
{
}
...
...
libs/pigment/resources/KoSegmentGradient.cpp
View file @
7ce9a273
...
...
@@ -255,30 +255,27 @@ KoGradientSegment::KoGradientSegment(int interpolationType, int colorInterpolati
if
(
startOffset
<
DBL_EPSILON
)
{
m_startOffset
=
0
;
}
else
if
(
startOffset
>
1
-
DBL_EPSILON
)
{
m_startOffset
=
1
;
}
else
{
m_startOffset
=
startOffset
;
}
}
else
if
(
startOffset
>
1
-
DBL_EPSILON
)
{
m_startOffset
=
1
;
}
else
{
m_startOffset
=
startOffset
;
}
if
(
middleOffset
<
m_startOffset
+
DBL_EPSILON
)
{
m_middleOffset
=
m_startOffset
;
}
else
if
(
middleOffset
>
1
-
DBL_EPSILON
)
{
m_middleOffset
=
1
;
}
else
{
m_middleOffset
=
middleOffset
;
}
}
else
if
(
middleOffset
>
1
-
DBL_EPSILON
)
{
m_middleOffset
=
1
;
}
else
{
m_middleOffset
=
middleOffset
;
}
if
(
endOffset
<
m_middleOffset
+
DBL_EPSILON
)
{
m_endOffset
=
m_middleOffset
;
}
else
if
(
endOffset
>
1
-
DBL_EPSILON
)
{
m_endOffset
=
1
;
}
else
{
m_endOffset
=
endOffset
;
}
}
else
if
(
endOffset
>
1
-
DBL_EPSILON
)
{
m_endOffset
=
1
;
}
else
{
m_endOffset
=
endOffset
;
}
m_length
=
m_endOffset
-
m_startOffset
;
...
...
libs/pigment/tests/TestKoColor.cpp
View file @
7ce9a273
...
...
@@ -31,7 +31,7 @@
bool
nearEqualValue
(
int
a
,
int
b
)
{
return
qAbs
(
a
-
b
)
<=
1
;
return
qAbs
(
a
-
b
)
<=
1
;
}
void
TestKoColor
::
testForModel
(
QString
model
)
...
...
libs/pigment/tests/TestKoIntegerMaths.cpp
View file @
7ce9a273
...
...
@@ -39,13 +39,13 @@ void TestKoIntegerMaths::UINT8Tests()
QCOMPARE
((
int
)
UINT8_DIVIDE
(
1
,
64
),
4
);
QCOMPARE
((
int
)
UINT8_DIVIDE
(
0
,
1
),
0
);
for
(
int
i
=
0
;
i
<
256
;
i
++
)
{
for
(
int
i
=
0
;
i
<
256
;
i
++
)
{
QCOMPARE
((
int
)
UINT8_BLEND
(
255
,
0
,
i
),
int
(
255.0
*
i
/
255.0
+
0.5
));
}
for
(
int
i
=
0
;
i
<
256
;
i
++
)
{
for
(
int
i
=
0
;
i
<
256
;
i
++
)
{
QCOMPARE
((
int
)
UINT8_BLEND
(
0
,
255
,
i
),
int
(
255.0
*
(
255
-
i
)
/
255.0
+
0.5
));
}
for
(
int
i
=
0
;
i
<
256
;
i
++
)
{
for
(
int
i
=
0
;
i
<
256
;
i
++
)
{
QCOMPARE
((
int
)
UINT8_BLEND
(
0
,
i
,
128
),
int
(
i
*
(
255
-
128
)
/
255.0
+
0.5
));
}
QCOMPARE
((
int
)
UINT8_BLEND
(
255
,
128
,
128
),
192
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment