aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorGreg Frieger2009-03-01 05:15:51 +0000
committerGreg Frieger2009-03-01 05:15:51 +0000
commit6742caa87a08e8c468b2eec5cf96c1dbc86fcb3a (patch)
tree1f14262b49bb0b6a96ad8de212cf10418145d723 /engines/sci
parentdd98126423d915c19baf43184ba40fb0d9a68b64 (diff)
downloadscummvm-rg350-6742caa87a08e8c468b2eec5cf96c1dbc86fcb3a.tar.gz
scummvm-rg350-6742caa87a08e8c468b2eec5cf96c1dbc86fcb3a.tar.bz2
scummvm-rg350-6742caa87a08e8c468b2eec5cf96c1dbc86fcb3a.zip
Text/window color matching improved by using an existing gfxop_set_color() instead of mine _gfxop_matchColor()
svn-id: r39004
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/gfx/operations.cpp27
1 files changed, 5 insertions, 22 deletions
diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp
index ae6d616756..61e25ff393 100644
--- a/engines/sci/gfx/operations.cpp
+++ b/engines/sci/gfx/operations.cpp
@@ -1002,24 +1002,6 @@ int gfxop_draw_rectangle(gfx_state_t *state, rect_t rect, gfx_color_t color, gfx
#define COLOR_MIX(type, dist) ((color1.type * dist) + (color2.type * (1.0 - dist)))
-int _gfxop_matchColor(gfx_state_t *state, const gfx_pixmap_color_t &color) {
- int i, delta, bestindex = -1, bestdelta = 200000;
-
- for (i = 0; i < state->static_palette_entries; i++) {
- int dr = abs(state->static_palette[i].r - color.r);
- int dg = abs(state->static_palette[i].g - color.g);
- int db = abs(state->static_palette[i].b - color.b);
-
- delta = dr * dr + dg * dg + db * db;
-
- if (delta < bestdelta) {
- bestdelta = delta;
- bestindex = i;
- }
- }
- return bestindex;
-}
-
int gfxop_draw_box(gfx_state_t *state, rect_t box, gfx_color_t color1, gfx_color_t color2, gfx_box_shade_t shade_type) {
gfx_driver_t *drv = state->driver;
int reverse = 0; // switch color1 and color2
@@ -1091,8 +1073,7 @@ int gfxop_draw_box(gfx_state_t *state, rect_t box, gfx_color_t color1, gfx_color
// Reverse offset if we have to interpret colors inversely
if (shade_type == GFX_BOX_SHADE_FLAT) {
- if (color1.visual.global_index == -1)
- color1.visual.global_index = _gfxop_matchColor(state, color1.visual);
+ gfxop_set_color(state, &color1, color1.visual.r, color1.visual.g, color1.visual.b, 0, 0, 0);
return drv->draw_filled_rect(drv, new_box, color1, color1, GFX_SHADE_FLAT);
} else {
if (PALETTE_MODE) {
@@ -1941,9 +1922,11 @@ int gfxop_draw_text(gfx_state_t *state, gfx_text_handle_t *handle, rect_t zone)
if (!pxm->data) {
// Matching pixmap's colors to current system palette if needed
+ gfx_color_t matched;
for (int j = 0; j < pxm->colors_nr; j++) {
- if (pxm->colors[j].global_index == -1)
- pxm->colors[j].global_index = _gfxop_matchColor(state, pxm->colors[j]);
+ gfxop_set_color(state, &matched, pxm->colors[j].r, pxm->colors[j].g, pxm->colors[j].b,
+ 0, 0, 0);
+ pxm->colors[j].global_index = matched.visual.global_index;
}
gfx_xlate_pixmap(pxm, state->driver->mode, state->options->text_xlate_filter);