Pass rle_remap arg by &

This commit is contained in:
Kp 2015-01-29 04:27:37 +00:00
parent 912253ab00
commit 27aeb6764d
3 changed files with 11 additions and 11 deletions

View file

@ -563,26 +563,26 @@ void rle_swap_0_255(grs_bitmap *bmp)
/*
* remaps all entries using colormap in an RLE bitmap without uncompressing it
*/
void rle_remap(grs_bitmap *bmp, array<color_t, 256> &colormap)
void rle_remap(grs_bitmap &bmp, array<color_t, 256> &colormap)
{
int len, rle_big;
unsigned char *start;
unsigned short line_size;
rle_big = bmp->bm_flags & BM_FLAG_RLE_BIG;
rle_big = bmp.bm_flags & BM_FLAG_RLE_BIG;
RAIIdmem<uint8_t[]> temp;
MALLOC(temp, uint8_t[], MAX_BMP_SIZE(bmp->bm_w, bmp->bm_h) + 30000);
MALLOC(temp, uint8_t[], MAX_BMP_SIZE(bmp.bm_w, bmp.bm_h) + 30000);
const std::size_t pointer_offset = rle_big ? 4 + 2 * bmp->bm_h : 4 + bmp->bm_h;
auto ptr = &bmp->bm_data[pointer_offset];
const std::size_t pointer_offset = rle_big ? 4 + 2 * bmp.bm_h : 4 + bmp.bm_h;
auto ptr = &bmp.get_bitmap_data()[pointer_offset];
auto ptr2 = &temp[pointer_offset];
for (int i = 0; i < bmp->bm_h; i++) {
for (int i = 0; i < bmp.bm_h; i++) {
start = ptr2;
if (rle_big)
line_size = INTEL_SHORT(*((unsigned short *)&bmp->bm_data[4 + 2 * i]));
line_size = INTEL_SHORT(*((unsigned short *)&bmp.get_bitmap_data()[4 + 2 * i]));
else
line_size = bmp->bm_data[4 + i];
line_size = bmp.get_bitmap_data()[4 + i];
for (int j = 0; j < line_size; j++) {
if ( ! IS_RLE_CODE(ptr[j])) {
if (IS_RLE_CODE(colormap[ptr[j]]))
@ -604,5 +604,5 @@ void rle_remap(grs_bitmap *bmp, array<color_t, 256> &colormap)
}
len = ptr2 - temp;
*((int *)(unsigned char *)temp) = len; // set total size
memcpy(bmp->get_bitmap_data(), temp, len);
memcpy(bmp.get_bitmap_data(), temp, len);
}

View file

@ -78,7 +78,7 @@ static inline const grs_bitmap *rle_expand_texture(const grs_bitmap &bmp)
void rle_cache_close();
void rle_cache_flush();
void rle_swap_0_255(grs_bitmap *bmp);
void rle_remap(grs_bitmap *bmp, array<color_t, 256> &colormap);
void rle_remap(grs_bitmap &bmp, array<color_t, 256> &colormap);
void gr_rle_expand_scanline_generic(grs_bitmap &dest, int dx, int dy, const ubyte *src, int x1, int x2 );
#endif

View file

@ -1841,7 +1841,7 @@ static void bitmap_read_d1( grs_bitmap *bitmap, /* read into this bitmap */
swap_0_255(bitmap);
}
if (bmh->flags & BM_FLAG_RLE)
rle_remap(bitmap, colormap);
rle_remap(*bitmap, colormap);
else
gr_remap_bitmap_good(*bitmap, d1_palette, TRANSPARENCY_COLOR, -1);
if (bmh->flags & BM_FLAG_RLE) { // size of bitmap could have changed!