Pass gr_bitmap_rle_compress arg by &
This commit is contained in:
parent
26544682e0
commit
912253ab00
|
@ -289,7 +289,7 @@ static unsigned gr_rle_getsize(int org_size, const uint8_t *src)
|
|||
return dest_size;
|
||||
}
|
||||
|
||||
int gr_bitmap_rle_compress( grs_bitmap * bmp )
|
||||
int gr_bitmap_rle_compress(grs_bitmap &bmp)
|
||||
{
|
||||
int d1;
|
||||
int doffset;
|
||||
|
@ -297,8 +297,8 @@ int gr_bitmap_rle_compress( grs_bitmap * bmp )
|
|||
|
||||
// first must check to see if this is large bitmap.
|
||||
|
||||
for (int y=0; y<bmp->bm_h; y++ ) {
|
||||
d1= gr_rle_getsize( bmp->bm_w, &bmp->bm_data[bmp->bm_w*y] );
|
||||
for (int y=0; y<bmp.bm_h; y++ ) {
|
||||
d1= gr_rle_getsize( bmp.bm_w, &bmp.get_bitmap_data()[bmp.bm_w*y] );
|
||||
if (d1 > 255) {
|
||||
large_rle = 1;
|
||||
break;
|
||||
|
@ -306,19 +306,19 @@ int gr_bitmap_rle_compress( grs_bitmap * bmp )
|
|||
}
|
||||
|
||||
RAIIdmem<uint8_t[]> rle_data;
|
||||
MALLOC(rle_data, uint8_t[], MAX_BMP_SIZE(bmp->bm_w, bmp->bm_h));
|
||||
MALLOC(rle_data, uint8_t[], MAX_BMP_SIZE(bmp.bm_w, bmp.bm_h));
|
||||
if (!rle_data) return 0;
|
||||
if (!large_rle)
|
||||
doffset = 4 + bmp->bm_h;
|
||||
doffset = 4 + bmp.bm_h;
|
||||
else
|
||||
doffset = 4 + (2 * bmp->bm_h); // each row of rle'd bitmap has short instead of byte offset now
|
||||
doffset = 4 + (2 * bmp.bm_h); // each row of rle'd bitmap has short instead of byte offset now
|
||||
|
||||
for (int y=0; y<bmp->bm_h; y++ ) {
|
||||
d1= gr_rle_getsize( bmp->bm_w, &bmp->bm_data[bmp->bm_w*y] );
|
||||
if ( ((doffset+d1) > bmp->bm_w*bmp->bm_h) || (d1 > (large_rle?32767:255) ) ) {
|
||||
for (int y=0; y<bmp.bm_h; y++ ) {
|
||||
d1= gr_rle_getsize( bmp.bm_w, &bmp.get_bitmap_data()[bmp.bm_w*y] );
|
||||
if ( ((doffset+d1) > bmp.bm_w*bmp.bm_h) || (d1 > (large_rle?32767:255) ) ) {
|
||||
return 0;
|
||||
}
|
||||
const auto d = gr_rle_encode( bmp->bm_w, &bmp->get_bitmap_data()[bmp->bm_w*y], &rle_data[doffset] );
|
||||
const auto d = gr_rle_encode( bmp.bm_w, &bmp.get_bitmap_data()[bmp.bm_w*y], &rle_data[doffset] );
|
||||
Assert( d==d1 );
|
||||
doffset += d;
|
||||
if (large_rle)
|
||||
|
@ -327,10 +327,10 @@ int gr_bitmap_rle_compress( grs_bitmap * bmp )
|
|||
rle_data[y+4] = d;
|
||||
}
|
||||
memcpy( rle_data, &doffset, 4 );
|
||||
memcpy(bmp->get_bitmap_data(), rle_data, doffset );
|
||||
bmp->bm_flags |= BM_FLAG_RLE;
|
||||
memcpy(bmp.get_bitmap_data(), rle_data, doffset );
|
||||
bmp.bm_flags |= BM_FLAG_RLE;
|
||||
if (large_rle)
|
||||
bmp->bm_flags |= BM_FLAG_RLE_BIG;
|
||||
bmp.bm_flags |= BM_FLAG_RLE_BIG;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,9 +61,10 @@ static inline rle_position_t rle_end(const T1 &src, T2 &dst)
|
|||
return {end(src), end(dst)};
|
||||
}
|
||||
|
||||
__attribute_warn_unused_result
|
||||
rle_position_t gr_rle_decode(rle_position_t b, const rle_position_t e);
|
||||
ubyte * gr_rle_find_xth_pixel( ubyte *src, int x,int * count, ubyte color );
|
||||
int gr_bitmap_rle_compress( grs_bitmap * bmp );
|
||||
int gr_bitmap_rle_compress(grs_bitmap &bmp);
|
||||
void gr_rle_expand_scanline_masked(uint8_t *dest, const uint8_t *src, int x1, int x2);
|
||||
void gr_rle_expand_scanline(uint8_t *dest, const uint8_t *src, int x1, int x2);
|
||||
grs_bitmap *_rle_expand_texture(const grs_bitmap &bmp);
|
||||
|
|
|
@ -291,7 +291,8 @@ bitmap_index piggy_register_bitmap( grs_bitmap * bmp, const char * name, int in_
|
|||
swap_0_255( bmp );
|
||||
#endif
|
||||
#endif
|
||||
if ( GameArg.DbgNoCompressPigBitmap ) gr_bitmap_rle_compress( bmp );
|
||||
if (GameArg.DbgNoCompressPigBitmap)
|
||||
gr_bitmap_rle_compress(*bmp);
|
||||
Num_bitmap_files_new++;
|
||||
}
|
||||
#if defined(DXX_BUILD_DESCENT_II)
|
||||
|
@ -869,7 +870,8 @@ void piggy_new_pigfile(char *pigname)
|
|||
if ( GameArg.EdiMacData )
|
||||
swap_0_255( bm[fnum].get() );
|
||||
|
||||
if ( GameArg.DbgNoCompressPigBitmap ) gr_bitmap_rle_compress( bm[fnum].get() );
|
||||
if (GameArg.DbgNoCompressPigBitmap)
|
||||
gr_bitmap_rle_compress(*bm[fnum].get());
|
||||
|
||||
if (bm[fnum]->bm_flags & BM_FLAG_RLE)
|
||||
size = *((int *) bm[fnum]->bm_data);
|
||||
|
@ -915,7 +917,8 @@ void piggy_new_pigfile(char *pigname)
|
|||
if ( GameArg.EdiMacData )
|
||||
swap_0_255( &n );
|
||||
|
||||
if ( GameArg.DbgNoCompressPigBitmap ) gr_bitmap_rle_compress( &n );
|
||||
if (GameArg.DbgNoCompressPigBitmap)
|
||||
gr_bitmap_rle_compress(n);
|
||||
|
||||
if (n.bm_flags & BM_FLAG_RLE)
|
||||
size = *((int *) n.bm_data);
|
||||
|
|
Loading…
Reference in a new issue