Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
f38cebcb
Kaydet (Commit)
f38cebcb
authored
May 06, 2011
tarafından
Jan Holesovsky
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Use the color conversion functions from basegfx.
üst
126308f0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
77 deletions
+15
-77
colorpicker.cxx
cui/source/dialogs/colorpicker.cxx
+15
-77
No files found.
cui/source/dialogs/colorpicker.cxx
Dosyayı görüntüle @
f38cebcb
...
...
@@ -59,18 +59,19 @@
#include <sax/tools/converter.hxx>
#include <basegfx/color/bcolortools.hxx>
#include "dialmgr.hxx"
#include "colorpicker.hrc"
#include <cmath>
#include <limits>
using
rtl
::
OUString
;
using
namespace
::
com
::
sun
::
star
::
uno
;
using
namespace
::
com
::
sun
::
star
::
lang
;
//using namespace ::com::sun::star::frame;
using
namespace
::
com
::
sun
::
star
::
ui
::
dialogs
;
using
namespace
::
com
::
sun
::
star
::
beans
;
using
namespace
::
basegfx
;
namespace
cui
{
...
...
@@ -92,87 +93,24 @@ const sal_uInt16 COLORCOMP_YELLOW = 0x41;
const
sal_uInt16
COLORCOMP_MAGENTA
=
0x42
;
const
sal_uInt16
COLORCOMP_KEY
=
0x43
;
// -----------------------------------------------------------------------
// color space conversion
// RGB = 0 .. 1
// H = 0 .. 360
// SV = 0 .. 1
// CMYK = 0 .. 1
// -----------------------------------------------------------------------
static
bool
equals
(
double
a
,
double
b
)
{
return
(
a
==
b
)
||
(
abs
(
a
-
b
)
<
std
::
numeric_limits
<
double
>::
epsilon
());
}
// color space conversion helpers
static
void
RGBtoHSV
(
double
dR
,
double
dG
,
double
dB
,
double
&
dH
,
double
&
dS
,
double
&
dV
)
{
// Brightness = max(R, G, B);
dV
=
std
::
max
(
dR
,
std
::
max
(
dG
,
dB
)
);
double
cDelta
=
dV
-
std
::
min
(
dR
,
std
::
min
(
dG
,
dB
)
);
// Saturation = max - min / max
if
(
dV
>
0
)
dS
=
cDelta
/
dV
;
else
dS
=
0.0
;
dH
=
0.0
;
if
(
!
equals
(
dS
,
0.0
)
)
{
if
(
equals
(
dR
,
dV
)
)
{
dH
=
(
dG
-
dB
)
/
cDelta
;
}
else
if
(
equals
(
dG
,
dV
)
)
{
dH
=
2.0
+
(
dB
-
dR
)
/
cDelta
;
}
else
if
(
equals
(
dB
,
dV
)
)
{
dH
=
4.0
+
(
dR
-
dG
)
/
cDelta
;
}
dH
*=
60.0
;
BColor
result
=
tools
::
rgb2hsv
(
BColor
(
dR
,
dG
,
dB
)
);
if
(
dH
<
0.0
)
dH
+=
360.0
;
}
dH
=
result
.
getX
();
dS
=
result
.
getY
()
;
dV
=
result
.
getZ
();
}
static
void
HSVtoRGB
(
double
dH
,
double
dS
,
double
dV
,
double
&
dR
,
double
&
dG
,
double
&
dB
)
{
if
(
equals
(
dS
,
0.0
)
)
{
dR
=
dV
;
dG
=
dV
;
dB
=
dV
;
}
else
{
if
(
equals
(
dH
,
360.0
)
)
dH
=
0.0
;
else
dH
/=
60.0
;
sal_uInt16
n
=
(
sal_uInt16
)
dH
;
double
f
=
dH
-
n
;
double
a
=
dV
*
(
1.0
-
dS
);
double
b
=
dV
*
(
1.0
-
(
dS
*
f
)
);
double
c
=
dV
*
(
1.0
-
(
dS
*
(
1.0
-
f
)
)
);
BColor
result
=
tools
::
hsv2rgb
(
BColor
(
dH
,
dS
,
dV
)
);
switch
(
n
)
{
case
0
:
dR
=
dV
;
dG
=
c
;
dB
=
a
;
break
;
case
1
:
dR
=
b
;
dG
=
dV
;
dB
=
a
;
break
;
case
2
:
dR
=
a
;
dG
=
dV
;
dB
=
c
;
break
;
case
3
:
dR
=
a
;
dG
=
b
;
dB
=
dV
;
break
;
case
4
:
dR
=
c
;
dG
=
a
;
dB
=
dV
;
break
;
case
5
:
dR
=
dV
;
dG
=
a
;
dB
=
b
;
break
;
}
}
dR
=
result
.
getRed
();
dG
=
result
.
getGreen
();
dB
=
result
.
getBlue
();
}
// -----------------------------------------------------------------------
...
...
@@ -204,7 +142,7 @@ static void RGBtoCMYK( double dR, double dG, double dB, double& fCyan, double& f
if
(
fMagenta
<
fKey
)
fKey
=
fMagenta
;
if
(
fYellow
<
fKey
)
fKey
=
fYellow
;
if
(
equals
(
fKey
,
1.0
)
)
if
(
fKey
>=
1.0
)
{
//Black
fCyan
=
0.0
;
...
...
@@ -1289,9 +1227,9 @@ ColorPickerDialog::ColorPickerDialog( Window* pParent, sal_Int32 nColor, sal_Int
// --------------------------------------------------------------------
static
int
toInt
(
double
dValue
,
double
b
Range
)
static
int
toInt
(
double
dValue
,
double
d
Range
)
{
return
static_cast
<
int
>
(
std
::
floor
((
dValue
*
b
Range
)
+
0.5
)
);
return
static_cast
<
int
>
(
std
::
floor
((
dValue
*
d
Range
)
+
0.5
)
);
}
sal_Int32
ColorPickerDialog
::
GetColor
()
const
...
...
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