aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/graphics
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2010-11-04 19:17:44 +0000
committerWillem Jan Palenstijn2010-11-04 19:17:44 +0000
commit7e6aa1b4a9cda2351c6716cfced0546aaa3d52d8 (patch)
tree44a0f7c5a93566cdf3c7fe8838b79a233900e2a1 /engines/sci/graphics
parentbb716c23fa939c89790859a43c7f9a5327a8a9cc (diff)
downloadscummvm-rg350-7e6aa1b4a9cda2351c6716cfced0546aaa3d52d8.tar.gz
scummvm-rg350-7e6aa1b4a9cda2351c6716cfced0546aaa3d52d8.tar.bz2
scummvm-rg350-7e6aa1b4a9cda2351c6716cfced0546aaa3d52d8.zip
SCI: Use gamma 2.2 for blending undithered colours
svn-id: r54069
Diffstat (limited to 'engines/sci/graphics')
-rw-r--r--engines/sci/graphics/palette.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp
index 76b2ed53fc..96646237ee 100644
--- a/engines/sci/graphics/palette.cpp
+++ b/engines/sci/graphics/palette.cpp
@@ -192,6 +192,16 @@ void GfxPalette::modifyAmigaPalette(byte *data) {
_screen->setPalette(&_sysPalette);
}
+static byte blendColours(byte c1, byte c2) {
+ // linear:
+ // return (c1/2+c2/2)+(c1&1+c2&1)/2;
+
+ // gamma 2.2
+ double t = 0.5 + (pow (c1/255.0, 2.2/1.0) * 255.0) +
+ 0.5 + (pow (c2/255.0, 2.2/1.0) * 255.0);
+ return (byte)(0.5 + (pow (0.5*t/255.0, 1.0/2.2) * 255.0));
+}
+
void GfxPalette::setEGA() {
int curColor;
byte color1, color2;
@@ -219,9 +229,10 @@ void GfxPalette::setEGA() {
for (curColor = 0x10; curColor <= 0xFE; curColor++) {
_sysPalette.colors[curColor].used = 1;
color1 = curColor & 0x0F; color2 = curColor >> 4;
- _sysPalette.colors[curColor].r = (_sysPalette.colors[color1].r >> 1) + (_sysPalette.colors[color2].r >> 1);
- _sysPalette.colors[curColor].g = (_sysPalette.colors[color1].g >> 1) + (_sysPalette.colors[color2].g >> 1);
- _sysPalette.colors[curColor].b = (_sysPalette.colors[color1].b >> 1) + (_sysPalette.colors[color2].b >> 1);
+
+ _sysPalette.colors[curColor].r = blendColours(_sysPalette.colors[color1].r, _sysPalette.colors[color2].r);
+ _sysPalette.colors[curColor].g = blendColours(_sysPalette.colors[color1].g, _sysPalette.colors[color2].g);
+ _sysPalette.colors[curColor].b = blendColours(_sysPalette.colors[color1].b, _sysPalette.colors[color2].b);
}
_sysPalette.timestamp = 1;
setOnScreen();