diff --git a/common/2d/bitmap.cpp b/common/2d/bitmap.cpp index 3405c2e39..9e451aa34 100644 --- a/common/2d/bitmap.cpp +++ b/common/2d/bitmap.cpp @@ -186,30 +186,30 @@ void gr_remap_bitmap( grs_bitmap * bmp, palette_array_t &palette, int transparen gr_set_super_transparent(*bmp, 0); } -void gr_remap_bitmap_good(grs_bitmap &bmp, palette_array_t &palette, int transparent_color, int super_transparent_color) +void gr_remap_bitmap_good(grs_bitmap &bmp, palette_array_t &palette, uint_fast32_t transparent_color, uint_fast32_t super_transparent_color) { array colormap; array freq; build_colormap_good( palette, colormap, freq ); - if ( (super_transparent_color>=0) && (super_transparent_color<=255)) + if (super_transparent_color < colormap.size()) colormap[super_transparent_color] = 254; - if ( (transparent_color>=0) && (transparent_color<=255)) + if (transparent_color < colormap.size()) colormap[transparent_color] = TRANSPARENCY_COLOR; if (bmp.bm_w == bmp.bm_rowsize) decode_data(bmp.get_bitmap_data(), bmp.bm_w * bmp.bm_h, colormap, freq ); else { auto p = bmp.get_bitmap_data(); - for (int y=0;y=0) && (transparent_color<=255) && (freq[transparent_color]>0) ) + if (transparent_color < freq.size() && freq[transparent_color]) gr_set_transparent(bmp, 1); - if ( (super_transparent_color>=0) && (super_transparent_color<=255) && (freq[super_transparent_color]>0) ) + if (super_transparent_color < freq.size() && freq[super_transparent_color]) gr_set_super_transparent(bmp, 1); } diff --git a/common/include/gr.h b/common/include/gr.h index 7fdcb0aef..4cf43dc99 100644 --- a/common/include/gr.h +++ b/common/include/gr.h @@ -456,7 +456,7 @@ void gr_remap_bitmap( grs_bitmap * bmp, palette_array_t &palette, int transparen // Same as above, but searches using gr_find_closest_color which uses // 18-bit accurracy instead of 15bit when translating colors. -void gr_remap_bitmap_good(grs_bitmap &bmp, palette_array_t &palette, int transparent_color, int super_transparent_color); +void gr_remap_bitmap_good(grs_bitmap &bmp, palette_array_t &palette, uint_fast32_t transparent_color, uint_fast32_t super_transparent_color); void gr_palette_step_up( int r, int g, int b );