mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 04:28:37 +00:00
Cine::Palette: Add fillWithBlack and saturatedAddNormalizedGray-methods.
svn-id: r39676
This commit is contained in:
parent
b85b6929bd
commit
51751cd069
@ -211,6 +211,16 @@ uint Palette::colorCount() const {
|
||||
return _colors.size();
|
||||
}
|
||||
|
||||
Palette &Palette::fillWithBlack() {
|
||||
for (uint i = 0; i < _colors.size(); i++) {
|
||||
_colors[i].r = 0;
|
||||
_colors[i].g = 0;
|
||||
_colors[i].b = 0;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
EndianType Palette::endianType() const {
|
||||
return (_bigEndian ? CINE_BIG_ENDIAN : CINE_LITTLE_ENDIAN);
|
||||
}
|
||||
@ -247,6 +257,16 @@ Palette &Palette::saturatedAddColor(Palette& output, byte firstIndex, byte lastI
|
||||
return output;
|
||||
}
|
||||
|
||||
Palette &Palette::saturatedAddNormalizedGray(Palette& output, byte firstIndex, byte lastIndex, double normalizedGray) {
|
||||
// Calculate the gray value rounded up away from zero
|
||||
const double signedHalf = ((normalizedGray >= 0) ? +0.5 : -0.5);
|
||||
const signed r = (signed)(_rMax * normalizedGray + signedHalf);
|
||||
const signed g = (signed)(_gMax * normalizedGray + signedHalf);
|
||||
const signed b = (signed)(_bMax * normalizedGray + signedHalf);
|
||||
|
||||
return saturatedAddColor(output, firstIndex, lastIndex, r, g, b);
|
||||
}
|
||||
|
||||
// a.k.a. transformColor
|
||||
// Parameter color components (i.e. r, g and b) are in range [-7, 7]
|
||||
// e.g. r = 7 sets the resulting color's red component to maximum
|
||||
|
@ -116,8 +116,11 @@ public:
|
||||
|
||||
Palette &rotateRight(byte firstIndex, byte lastIndex);
|
||||
Palette &saturatedAddColor(Palette& output, byte firstIndex, byte lastIndex, signed r, signed g, signed b);
|
||||
Palette &saturatedAddNormalizedGray(Palette& output, byte firstIndex, byte lastIndex, double normalizedGray);
|
||||
uint colorCount() const;
|
||||
|
||||
Palette &fillWithBlack();
|
||||
|
||||
/*! \brief The original endian type in which this palette was loaded.
|
||||
* \note This will always return either CINE_BIG_ENDIAN or CINE_LITTLE_ENDIAN (So no CINE_NATIVE_ENDIAN).
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user