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
ef968e13
Kaydet (Commit)
ef968e13
authored
Nis 21, 2015
tarafından
Tomaž Vajngerl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
cleanup tools/color.hxx
Change-Id: I7d8f263f9ccb1ea4f230d7a2df4d88c408b3a5da
üst
362c1b18
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
101 additions
and
69 deletions
+101
-69
color.hxx
include/tools/color.hxx
+101
-69
No files found.
include/tools/color.hxx
Dosyayı görüntüle @
ef968e13
...
@@ -91,88 +91,120 @@ typedef sal_uInt32 ColorData;
...
@@ -91,88 +91,120 @@ typedef sal_uInt32 ColorData;
class
TOOLS_DLLPUBLIC
SAL_WARN_UNUSED
Color
class
TOOLS_DLLPUBLIC
SAL_WARN_UNUSED
Color
{
{
protected
:
protected
:
ColorData
mnColor
;
ColorData
mnColor
;
public
:
public
:
Color
()
{
mnColor
=
COL_BLACK
;
}
Color
()
Color
(
ColorData
nColor
)
{
mnColor
=
nColor
;
}
:
mnColor
(
COL_BLACK
)
Color
(
sal_uInt8
nRed
,
sal_uInt8
nGreen
,
sal_uInt8
nBlue
)
{}
{
mnColor
=
RGB_COLORDATA
(
nRed
,
nGreen
,
nBlue
);
}
Color
(
ColorData
nColor
)
Color
(
sal_uInt8
nTransparency
,
sal_uInt8
nRed
,
sal_uInt8
nGreen
,
sal_uInt8
nBlue
)
:
mnColor
(
nColor
)
{
mnColor
=
TRGB_COLORDATA
(
nTransparency
,
nRed
,
nGreen
,
nBlue
);
}
{}
// This ctor is defined in svtools, not tools!
Color
(
sal_uInt8
nRed
,
sal_uInt8
nGreen
,
sal_uInt8
nBlue
)
Color
(
const
ResId
&
rResId
);
:
mnColor
(
RGB_COLORDATA
(
nRed
,
nGreen
,
nBlue
))
{}
// constructor to create a tools-Color from ::basegfx::BColor
Color
(
sal_uInt8
nTransparency
,
sal_uInt8
nRed
,
sal_uInt8
nGreen
,
sal_uInt8
nBlue
)
explicit
Color
(
const
::
basegfx
::
BColor
&
rBColor
)
:
mnColor
(
TRGB_COLORDATA
(
nTransparency
,
nRed
,
nGreen
,
nBlue
))
{
{}
mnColor
=
RGB_COLORDATA
(
// This ctor is defined in svtools, not tools!
sal_uInt8
((
rBColor
.
getRed
()
*
255.0
)
+
0.5
),
Color
(
const
ResId
&
rResId
);
// constructor to create a tools-Color from ::basegfx::BColor
explicit
Color
(
const
basegfx
::
BColor
&
rBColor
)
:
mnColor
(
RGB_COLORDATA
(
sal_uInt8
((
rBColor
.
getRed
()
*
255.0
)
+
0.5
),
sal_uInt8
((
rBColor
.
getGreen
()
*
255.0
)
+
0.5
),
sal_uInt8
((
rBColor
.
getGreen
()
*
255.0
)
+
0.5
),
sal_uInt8
((
rBColor
.
getBlue
()
*
255.0
)
+
0.5
));
sal_uInt8
((
rBColor
.
getBlue
()
*
255.0
)
+
0.5
)))
}
{}
bool
operator
<
(
const
Color
&
b
)
const
bool
operator
<
(
const
Color
&
b
)
const
{
{
return
mnColor
<
b
.
GetColor
();
return
mnColor
<
b
.
GetColor
();
}
}
void
SetRed
(
sal_uInt8
nRed
);
void
SetRed
(
sal_uInt8
nRed
);
sal_uInt8
GetRed
()
const
{
return
COLORDATA_RED
(
mnColor
);
}
sal_uInt8
GetRed
()
const
void
SetGreen
(
sal_uInt8
nGreen
);
{
sal_uInt8
GetGreen
()
const
{
return
COLORDATA_GREEN
(
mnColor
);
}
return
COLORDATA_RED
(
mnColor
);
void
SetBlue
(
sal_uInt8
nBlue
);
}
sal_uInt8
GetBlue
()
const
{
return
COLORDATA_BLUE
(
mnColor
);
}
void
SetGreen
(
sal_uInt8
nGreen
);
void
SetTransparency
(
sal_uInt8
nTransparency
);
sal_uInt8
GetGreen
()
const
sal_uInt8
GetTransparency
()
const
{
return
COLORDATA_TRANSPARENCY
(
mnColor
);
}
{
return
COLORDATA_GREEN
(
mnColor
);
void
SetColor
(
ColorData
nColor
)
{
mnColor
=
nColor
;
}
}
ColorData
GetColor
()
const
{
return
mnColor
;
}
void
SetBlue
(
sal_uInt8
nBlue
);
ColorData
GetRGBColor
()
const
{
return
COLORDATA_RGB
(
mnColor
);
}
sal_uInt8
GetBlue
()
const
{
sal_uInt8
GetColorError
(
const
Color
&
rCompareColor
)
const
;
return
COLORDATA_BLUE
(
mnColor
);
}
sal_uInt8
GetLuminance
()
const
;
void
SetTransparency
(
sal_uInt8
nTransparency
);
void
IncreaseLuminance
(
sal_uInt8
cLumInc
);
sal_uInt8
GetTransparency
()
const
void
DecreaseLuminance
(
sal_uInt8
cLumDec
);
{
return
COLORDATA_TRANSPARENCY
(
mnColor
);
void
DecreaseContrast
(
sal_uInt8
cContDec
);
}
void
Invert
();
void
SetColor
(
ColorData
nColor
)
{
void
Merge
(
const
Color
&
rMergeColor
,
sal_uInt8
cTransparency
);
mnColor
=
nColor
;
}
bool
IsRGBEqual
(
const
Color
&
rColor
)
const
;
ColorData
GetColor
()
const
{
return
mnColor
;
}
ColorData
GetRGBColor
()
const
{
return
COLORDATA_RGB
(
mnColor
);
}
sal_uInt8
GetColorError
(
const
Color
&
rCompareColor
)
const
;
sal_uInt8
GetLuminance
()
const
;
void
IncreaseLuminance
(
sal_uInt8
cLumInc
);
void
DecreaseLuminance
(
sal_uInt8
cLumDec
);
void
DecreaseContrast
(
sal_uInt8
cContDec
);
void
Invert
();
void
Merge
(
const
Color
&
rMergeColor
,
sal_uInt8
cTransparency
);
bool
IsRGBEqual
(
const
Color
&
rColor
)
const
;
// comparison with luminance thresholds
// comparison with luminance thresholds
bool
IsDark
()
const
;
bool
IsDark
()
const
;
bool
IsBright
()
const
;
bool
IsBright
()
const
;
// color space conversion tools
// color space conversion tools
// the range for h/s/b is:
// the range for h/s/b is:
// Hue: 0-360 degree
// Hue: 0-360 degree
// Saturation: 0-100%
// Saturation: 0-100%
// Brightness: 0-100%
// Brightness: 0-100%
static
ColorData
HSBtoRGB
(
sal_uInt16
nHue
,
sal_uInt16
nSat
,
sal_uInt16
nBri
);
static
ColorData
HSBtoRGB
(
sal_uInt16
nHue
,
sal_uInt16
nSaturation
,
sal_uInt16
nBrightness
);
void
RGBtoHSB
(
sal_uInt16
&
nHue
,
sal_uInt16
&
nSat
,
sal_uInt16
&
nBri
)
const
;
void
RGBtoHSB
(
sal_uInt16
&
nHue
,
sal_uInt16
&
nSaturation
,
sal_uInt16
&
nBrightness
)
const
;
bool
operator
==
(
const
Color
&
rColor
)
const
bool
operator
==
(
const
Color
&
rColor
)
const
{
return
(
mnColor
==
rColor
.
mnColor
);
}
{
bool
operator
!=
(
const
Color
&
rColor
)
const
return
mnColor
==
rColor
.
mnColor
;
{
return
!
(
Color
::
operator
==
(
rColor
));
}
}
bool
operator
!=
(
const
Color
&
rColor
)
const
{
return
!
(
Color
::
operator
==
(
rColor
));
}
SvStream
&
Read
(
SvStream
&
rIStm
,
bool
bNewFormat
=
true
);
SvStream
&
Read
(
SvStream
&
rIStream
,
bool
bNewFormat
=
true
);
SvStream
&
Write
(
SvStream
&
rOStm
,
bool
bNewFormat
=
true
);
SvStream
&
Write
(
SvStream
&
rOStream
,
bool
bNewFormat
=
true
);
TOOLS_DLLPUBLIC
friend
SvStream
&
ReadColor
(
SvStream
&
rIStream
,
Color
&
rColor
);
TOOLS_DLLPUBLIC
friend
SvStream
&
ReadColor
(
SvStream
&
rIStream
,
Color
&
rColor
);
TOOLS_DLLPUBLIC
friend
SvStream
&
WriteColor
(
SvStream
&
rOStream
,
const
Color
&
rColor
);
TOOLS_DLLPUBLIC
friend
SvStream
&
WriteColor
(
SvStream
&
rOStream
,
const
Color
&
rColor
);
// Return color as RGB hex string
// Return color as RGB hex string
// for example "00ff00" for green color
// for example "00ff00" for green color
OUString
AsRGBHexString
()
const
;
OUString
AsRGBHexString
()
const
;
// get ::basegfx::BColor from this color
// get ::basegfx::BColor from this color
::
basegfx
::
BColor
getBColor
()
const
{
return
::
basegfx
::
BColor
(
GetRed
()
/
255.0
,
GetGreen
()
/
255.0
,
GetBlue
()
/
255.0
);
}
basegfx
::
BColor
getBColor
()
const
{
return
basegfx
::
BColor
(
GetRed
()
/
255.0
,
GetGreen
()
/
255.0
,
GetBlue
()
/
255.0
);
}
};
};
inline
void
Color
::
SetRed
(
sal_uInt8
nRed
)
inline
void
Color
::
SetRed
(
sal_uInt8
nRed
)
...
@@ -201,21 +233,21 @@ inline void Color::SetTransparency( sal_uInt8 nTransparency )
...
@@ -201,21 +233,21 @@ inline void Color::SetTransparency( sal_uInt8 nTransparency )
inline
bool
Color
::
IsRGBEqual
(
const
Color
&
rColor
)
const
inline
bool
Color
::
IsRGBEqual
(
const
Color
&
rColor
)
const
{
{
return
(
COLORDATA_RGB
(
mnColor
)
==
COLORDATA_RGB
(
rColor
.
mnColor
)
);
return
COLORDATA_RGB
(
mnColor
)
==
COLORDATA_RGB
(
rColor
.
mnColor
);
}
}
inline
sal_uInt8
Color
::
GetLuminance
()
const
inline
sal_uInt8
Color
::
GetLuminance
()
const
{
{
return
(
(
sal_uInt8
)
(
(
COLORDATA_BLUE
(
mnColor
)
*
29UL
+
return
static_cast
<
sal_uInt8
>
((
COLORDATA_BLUE
(
mnColor
)
*
29UL
+
COLORDATA_GREEN
(
mnColor
)
*
151UL
+
COLORDATA_GREEN
(
mnColor
)
*
151UL
+
COLORDATA_RED
(
mnColor
)
*
76UL
)
>>
8UL
)
);
COLORDATA_RED
(
mnColor
)
*
76UL
)
>>
8UL
);
}
}
inline
void
Color
::
Merge
(
const
Color
&
rMergeColor
,
sal_uInt8
cTransparency
)
inline
void
Color
::
Merge
(
const
Color
&
rMergeColor
,
sal_uInt8
cTransparency
)
{
{
SetRed
(
COLOR_CHANNEL_MERGE
(
COLORDATA_RED
(
mnColor
),
COLORDATA_RED
(
rMergeColor
.
mnColor
),
cTransparency
)
);
SetRed
(
COLOR_CHANNEL_MERGE
(
COLORDATA_RED
(
mnColor
),
COLORDATA_RED
(
rMergeColor
.
mnColor
),
cTransparency
)
);
SetGreen
(
COLOR_CHANNEL_MERGE
(
COLORDATA_GREEN
(
mnColor
),
COLORDATA_GREEN
(
rMergeColor
.
mnColor
),
cTransparency
)
);
SetGreen
(
COLOR_CHANNEL_MERGE
(
COLORDATA_GREEN
(
mnColor
),
COLORDATA_GREEN
(
rMergeColor
.
mnColor
),
cTransparency
)
);
SetBlue
(
COLOR_CHANNEL_MERGE
(
COLORDATA_BLUE
(
mnColor
),
COLORDATA_BLUE
(
rMergeColor
.
mnColor
),
cTransparency
)
);
SetBlue
(
COLOR_CHANNEL_MERGE
(
COLORDATA_BLUE
(
mnColor
),
COLORDATA_BLUE
(
rMergeColor
.
mnColor
),
cTransparency
)
);
}
}
#endif
#endif
...
...
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