mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Make implicit palette entries opaque black
This commit is contained in:
1 parent
2d39c6a802
commit
ece4eea1af
2 files changed
+8
-25
No files matched your search
@@ -2384,8 +2384,6 @@ typedef struct {
|
||||
bool f_end_of_data;
|
||||
bool f_previous_lzw_decode_ended_abruptly;
|
||||
bool f_previous_use_global_palette;
|
||||
bool f_has_full_global_palette;
|
||||
bool f_has_full_palette;
|
||||
bool f_use_local_palette;
|
||||
uint8_t f_which_palette;
|
||||
uint8_t f_interlace;
|
||||
@@ -6354,8 +6352,7 @@ wuffs_gif__decoder__decode_image_config(wuffs_gif__decoder* self,
|
||||
(self->private_impl.f_frame_rect_x0 == 0) &&
|
||||
(self->private_impl.f_frame_rect_y0 == 0) &&
|
||||
(self->private_impl.f_frame_rect_x1 == self->private_impl.f_width) &&
|
||||
(self->private_impl.f_frame_rect_y1 == self->private_impl.f_height) &&
|
||||
self->private_impl.f_has_full_palette);
|
||||
(self->private_impl.f_frame_rect_y1 == self->private_impl.f_height));
|
||||
if (a_dst != NULL) {
|
||||
wuffs_base__image_config__initialize(
|
||||
a_dst, 570984584, 0, self->private_impl.f_width,
|
||||
@@ -7021,12 +7018,11 @@ wuffs_gif__decoder__decode_lsd(wuffs_gif__decoder* self,
|
||||
((uint8_t)(((v_argb >> 24) & 255)));
|
||||
v_i += 1;
|
||||
}
|
||||
self->private_impl.f_has_full_global_palette = (v_i == 256);
|
||||
while (v_i < 256) {
|
||||
self->private_impl.f_palettes[0][((4 * v_i) + 0)] = 0;
|
||||
self->private_impl.f_palettes[0][((4 * v_i) + 1)] = 0;
|
||||
self->private_impl.f_palettes[0][((4 * v_i) + 2)] = 0;
|
||||
self->private_impl.f_palettes[0][((4 * v_i) + 3)] = 0;
|
||||
self->private_impl.f_palettes[0][((4 * v_i) + 3)] = 255;
|
||||
v_i += 1;
|
||||
}
|
||||
}
|
||||
@@ -7775,8 +7771,6 @@ wuffs_gif__decoder__decode_id_part0(wuffs_gif__decoder* self,
|
||||
} else {
|
||||
self->private_impl.f_interlace = 0;
|
||||
}
|
||||
self->private_impl.f_has_full_palette =
|
||||
self->private_impl.f_has_full_global_palette;
|
||||
self->private_impl.f_use_local_palette = ((v_flags & 128) != 0);
|
||||
if (self->private_impl.f_use_local_palette) {
|
||||
v_num_palette_entries = (((uint32_t)(1)) << (1 + (v_flags & 7)));
|
||||
@@ -7822,12 +7816,11 @@ wuffs_gif__decoder__decode_id_part0(wuffs_gif__decoder* self,
|
||||
((uint8_t)(((v_argb >> 24) & 255)));
|
||||
v_i += 1;
|
||||
}
|
||||
self->private_impl.f_has_full_palette = (v_i == 256);
|
||||
while (v_i < 256) {
|
||||
self->private_impl.f_palettes[1][((4 * v_i) + 0)] = 0;
|
||||
self->private_impl.f_palettes[1][((4 * v_i) + 1)] = 0;
|
||||
self->private_impl.f_palettes[1][((4 * v_i) + 2)] = 0;
|
||||
self->private_impl.f_palettes[1][((4 * v_i) + 3)] = 0;
|
||||
self->private_impl.f_palettes[1][((4 * v_i) + 3)] = 255;
|
||||
v_i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,8 +76,6 @@ pub struct decoder?(
|
||||
previous_lzw_decode_ended_abruptly base.bool,
|
||||
previous_use_global_palette base.bool,
|
||||
|
||||
has_full_global_palette base.bool,
|
||||
has_full_palette base.bool,
|
||||
use_local_palette base.bool,
|
||||
|
||||
which_palette base.u8[..2],
|
||||
@@ -139,8 +137,7 @@ pub func decoder.decode_image_config!??(dst nptr base.image_config, src base.io_
|
||||
(this.frame_rect_x0 == 0) and
|
||||
(this.frame_rect_y0 == 0) and
|
||||
(this.frame_rect_x1 == this.width) and
|
||||
(this.frame_rect_y1 == this.height) and
|
||||
(this.has_full_palette)
|
||||
(this.frame_rect_y1 == this.height)
|
||||
|
||||
if args.dst != nullptr {
|
||||
// TODO: rename initialize to set?
|
||||
@@ -319,16 +316,12 @@ pri func decoder.decode_lsd!??(src base.io_reader) {
|
||||
this.palettes[0][(4 * i) + 3] = ((argb >> 24) & 0xFF) as base.u8
|
||||
i += 1
|
||||
}
|
||||
this.has_full_global_palette = i == 256
|
||||
// Set the remaining palette entries to transparent black.
|
||||
//
|
||||
// TODO: opaque black?? Is this consistent with frame_config.blend?
|
||||
// Should we mask the LZW-decoded data if num_palette_entries < 256?
|
||||
// Set the remaining palette entries to opaque black.
|
||||
while i < 256 {
|
||||
this.palettes[0][(4 * i) + 0] = 0x00
|
||||
this.palettes[0][(4 * i) + 1] = 0x00
|
||||
this.palettes[0][(4 * i) + 2] = 0x00
|
||||
this.palettes[0][(4 * i) + 3] = 0x00
|
||||
this.palettes[0][(4 * i) + 3] = 0xFF
|
||||
i += 1
|
||||
}
|
||||
}
|
||||
@@ -517,8 +510,6 @@ pri func decoder.decode_id_part0!??(src base.io_reader) {
|
||||
this.interlace = 0
|
||||
}
|
||||
|
||||
this.has_full_palette = this.has_full_global_palette
|
||||
|
||||
// Read the optional Local Color Table.
|
||||
this.use_local_palette = (flags & 0x80) != 0
|
||||
if this.use_local_palette {
|
||||
@@ -535,13 +526,12 @@ pri func decoder.decode_id_part0!??(src base.io_reader) {
|
||||
this.palettes[1][(4 * i) + 3] = ((argb >> 24) & 0xFF) as base.u8
|
||||
i += 1
|
||||
}
|
||||
this.has_full_palette = i == 256
|
||||
// Set the remaining palette entries to transparent black.
|
||||
// Set the remaining palette entries to opaque black.
|
||||
while i < 256 {
|
||||
this.palettes[1][(4 * i) + 0] = 0x00
|
||||
this.palettes[1][(4 * i) + 1] = 0x00
|
||||
this.palettes[1][(4 * i) + 2] = 0x00
|
||||
this.palettes[1][(4 * i) + 3] = 0x00
|
||||
this.palettes[1][(4 * i) + 3] = 0xFF
|
||||
i += 1
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user