diff options
author | James Shaw <jshaw@netsurf-browser.org> | 2007-11-28 17:22:36 +0000 |
---|---|---|
committer | James Shaw <jshaw@netsurf-browser.org> | 2007-11-28 17:22:36 +0000 |
commit | 2cdf0f9615f2c8c2f9c73619c967dd6cda5bba0f (patch) | |
tree | 5a2d401233c93996d88bf9a09528e16781b3cc63 /trunk/libsprite.c | |
parent | aa9395bfc965e4a6974f8b2d84760646534f321f (diff) | |
download | librosprite-2cdf0f9615f2c8c2f9c73619c967dd6cda5bba0f.tar.gz |
Implement mask handling for high colour sprites
svn path=/import/jshaw/libsprite/; revision=10000
Diffstat (limited to 'trunk/libsprite.c')
-rw-r--r-- | trunk/libsprite.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/trunk/libsprite.c b/trunk/libsprite.c index 3e1d90e..464badd 100644 --- a/trunk/libsprite.c +++ b/trunk/libsprite.c @@ -409,7 +409,8 @@ uint32_t sprite_next_mask_pixel(uint8_t* mask, struct sprite_mask_state* mask_st void sprite_load_high_color(uint8_t* image_in, uint8_t* mask, struct sprite* sprite, struct sprite_header* header) { - mask = mask; + struct sprite_mask_state* mask_state = NULL; + if (sprite->has_mask) mask_state = sprite_init_mask_state(sprite, header, mask); sprite->image = malloc(sprite->width * sprite->height * 4); /* all image data is 32bpp going out */ @@ -431,6 +432,11 @@ void sprite_load_high_color(uint8_t* image_in, uint8_t* mask, struct sprite* spr } pixel = sprite_upscale_color(pixel, sprite->mode); + /* TODO: handle photodesk-style 0xBBGGRRAA sprites */ + if (sprite->has_mask) { + uint8_t mask_pixel = sprite_next_mask_pixel(mask, mask_state); + pixel = (pixel & 0xffffff00) | mask_pixel; + } sprite->image[y*sprite->width + x_pixels] = pixel; x_pixels++; } @@ -440,6 +446,8 @@ void sprite_load_high_color(uint8_t* image_in, uint8_t* mask, struct sprite* spr currentByteIndex = (currentByteIndex + 3) & ~3; /* Round up to next multiple of 4 */ } } + + if (sprite->has_mask) free(mask_state); } void sprite_load_low_color(uint8_t* image_in, uint8_t* mask, struct sprite* sprite, struct sprite_header* header) |