From b369d233ce32277d9e25dd31ba12f3617c38af57 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Fri, 20 Sep 2024 13:38:26 +0930 Subject: [PATCH] std: fix frame config background_color re alpha --- internal/cgen/base/image-public.h | 13 ++++++ lang/builtin/builtin.go | 1 + release/c/wuffs-unsupported-snapshot.c | 56 +++++++++++++++++++++----- std/bmp/decode_bmp.wuffs | 5 ++- std/etc2/decode_etc2.wuffs | 5 ++- std/netpbm/decode_netpbm.wuffs | 2 +- std/nie/decode_nie.wuffs | 5 ++- std/png/decode_png.wuffs | 4 +- std/qoi/decode_qoi.wuffs | 5 ++- std/targa/decode_targa.wuffs | 5 ++- std/thumbhash/decode_thumbhash.wuffs | 5 ++- std/vp8/decode_vp8.wuffs | 2 +- std/webp/decode_webp.wuffs | 5 ++- test/nia-checksums-of-data.txt | 8 ++-- 14 files changed, 97 insertions(+), 24 deletions(-) diff --git a/internal/cgen/base/image-public.h b/internal/cgen/base/image-public.h index 41c310e8..6aa5084c 100644 --- a/internal/cgen/base/image-public.h +++ b/internal/cgen/base/image-public.h @@ -399,6 +399,7 @@ typedef struct wuffs_base__pixel_format__struct { #ifdef __cplusplus inline bool is_valid() const; inline uint32_t bits_per_pixel() const; + inline uint32_t default_background_color() const; inline bool is_direct() const; inline bool is_indexed() const; inline bool is_interleaved() const; @@ -491,6 +492,13 @@ wuffs_base__pixel_format__bits_per_pixel(const wuffs_base__pixel_format* f) { (f->repr >> 12)]; } +static inline uint32_t // +wuffs_base__pixel_format__default_background_color( + const wuffs_base__pixel_format* f) { + return ((f->repr & 0x03000000) == 0) ? 0xFF000000 // Opaque black. + : 0x00000000; // Transparent black. +} + static inline bool // wuffs_base__pixel_format__is_direct(const wuffs_base__pixel_format* f) { return ((f->repr >> 18) & 0x01) == 0; @@ -539,6 +547,11 @@ wuffs_base__pixel_format::bits_per_pixel() const { return wuffs_base__pixel_format__bits_per_pixel(this); } +inline uint32_t // +wuffs_base__pixel_format::default_background_color() const { + return wuffs_base__pixel_format__default_background_color(this); +} + inline bool // wuffs_base__pixel_format::is_direct() const { return wuffs_base__pixel_format__is_direct(this); diff --git a/lang/builtin/builtin.go b/lang/builtin/builtin.go index b216d740..efdb6bb8 100644 --- a/lang/builtin/builtin.go +++ b/lang/builtin/builtin.go @@ -684,6 +684,7 @@ var funcsOther = [...]string{ // ---- pixel_format "pixel_format.bits_per_pixel() u32[..= 256]", + "pixel_format.default_background_color() u32", // ---- pixel_swizzler diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index eb9c289c..eac5a462 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -4438,6 +4438,7 @@ typedef struct wuffs_base__pixel_format__struct { #ifdef __cplusplus inline bool is_valid() const; inline uint32_t bits_per_pixel() const; + inline uint32_t default_background_color() const; inline bool is_direct() const; inline bool is_indexed() const; inline bool is_interleaved() const; @@ -4530,6 +4531,13 @@ wuffs_base__pixel_format__bits_per_pixel(const wuffs_base__pixel_format* f) { (f->repr >> 12)]; } +static inline uint32_t // +wuffs_base__pixel_format__default_background_color( + const wuffs_base__pixel_format* f) { + return ((f->repr & 0x03000000) == 0) ? 0xFF000000 // Opaque black. + : 0x00000000; // Transparent black. +} + static inline bool // wuffs_base__pixel_format__is_direct(const wuffs_base__pixel_format* f) { return ((f->repr >> 18) & 0x01) == 0; @@ -4578,6 +4586,11 @@ wuffs_base__pixel_format::bits_per_pixel() const { return wuffs_base__pixel_format__bits_per_pixel(this); } +inline uint32_t // +wuffs_base__pixel_format::default_background_color() const { + return wuffs_base__pixel_format__default_background_color(this); +} + inline bool // wuffs_base__pixel_format::is_direct() const { return wuffs_base__pixel_format__is_direct(this); @@ -34636,6 +34649,8 @@ wuffs_bmp__decoder__do_decode_frame_config( wuffs_base__io_buffer* a_src) { wuffs_base__status status = wuffs_base__make_status(NULL); + wuffs_base__pixel_format v_pixfmt = {0}; + const uint8_t* iop_a_src = NULL; const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; @@ -34678,6 +34693,7 @@ wuffs_bmp__decoder__do_decode_frame_config( goto ok; } if (a_dst != NULL) { + v_pixfmt = wuffs_base__utility__make_pixel_format(self->private_impl.f_src_pixfmt); wuffs_base__frame_config__set( a_dst, wuffs_base__utility__make_rect_ie_u32( @@ -34691,7 +34707,7 @@ wuffs_bmp__decoder__do_decode_frame_config( 0u, true, false, - 4278190080u); + wuffs_base__pixel_format__default_background_color(&v_pixfmt)); } self->private_impl.f_call_sequence = 64u; @@ -43549,6 +43565,8 @@ wuffs_etc2__decoder__do_decode_frame_config( wuffs_base__io_buffer* a_src) { wuffs_base__status status = wuffs_base__make_status(NULL); + wuffs_base__pixel_format v_pixfmt = {0}; + const uint8_t* iop_a_src = NULL; const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; @@ -43591,6 +43609,7 @@ wuffs_etc2__decoder__do_decode_frame_config( goto ok; } if (a_dst != NULL) { + v_pixfmt = wuffs_base__utility__make_pixel_format(self->private_impl.f_pixfmt); wuffs_base__frame_config__set( a_dst, wuffs_base__utility__make_rect_ie_u32( @@ -43604,7 +43623,7 @@ wuffs_etc2__decoder__do_decode_frame_config( 0u, (self->private_impl.f_pixfmt == 2415954056u), false, - 4278190080u); + wuffs_base__pixel_format__default_background_color(&v_pixfmt)); } self->private_impl.f_call_sequence = 64u; @@ -62544,7 +62563,7 @@ wuffs_netpbm__decoder__do_decode_frame_config( 0u, false, false, - 0u); + 4278190080u); } self->private_impl.f_call_sequence = 64u; @@ -63549,6 +63568,8 @@ wuffs_nie__decoder__do_decode_frame_config( wuffs_base__io_buffer* a_src) { wuffs_base__status status = wuffs_base__make_status(NULL); + wuffs_base__pixel_format v_pixfmt = {0}; + const uint8_t* iop_a_src = NULL; const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; @@ -63591,6 +63612,7 @@ wuffs_nie__decoder__do_decode_frame_config( goto ok; } if (a_dst != NULL) { + v_pixfmt = wuffs_base__utility__make_pixel_format(self->private_impl.f_pixfmt); wuffs_base__frame_config__set( a_dst, wuffs_base__utility__make_rect_ie_u32( @@ -63604,7 +63626,7 @@ wuffs_nie__decoder__do_decode_frame_config( 0u, false, false, - 0u); + wuffs_base__pixel_format__default_background_color(&v_pixfmt)); } self->private_impl.f_call_sequence = 64u; @@ -69002,6 +69024,7 @@ wuffs_png__decoder__do_decode_frame_config( wuffs_base__status status = wuffs_base__make_status(NULL); uint32_t v_checksum_have = 0; + wuffs_base__pixel_format v_pixfmt = {0}; const uint8_t* iop_a_src = NULL; const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; @@ -69226,6 +69249,7 @@ wuffs_png__decoder__do_decode_frame_config( } } if (a_dst != NULL) { + v_pixfmt = wuffs_base__utility__make_pixel_format(self->private_impl.f_src_pixfmt); wuffs_base__frame_config__set( a_dst, wuffs_base__utility__make_rect_ie_u32( @@ -69239,7 +69263,7 @@ wuffs_png__decoder__do_decode_frame_config( self->private_impl.f_frame_disposal, ((self->private_impl.f_color_type <= 3u) && ! self->private_impl.f_seen_trns), self->private_impl.f_frame_overwrite_instead_of_blend, - 0u); + wuffs_base__pixel_format__default_background_color(&v_pixfmt)); } wuffs_private_impl__u32__sat_add_indirect(&self->private_impl.f_num_decoded_frame_configs_value, 1u); self->private_impl.f_call_sequence = 64u; @@ -71685,6 +71709,8 @@ wuffs_qoi__decoder__do_decode_frame_config( wuffs_base__io_buffer* a_src) { wuffs_base__status status = wuffs_base__make_status(NULL); + wuffs_base__pixel_format v_pixfmt = {0}; + const uint8_t* iop_a_src = NULL; const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; @@ -71727,6 +71753,7 @@ wuffs_qoi__decoder__do_decode_frame_config( goto ok; } if (a_dst != NULL) { + v_pixfmt = wuffs_base__utility__make_pixel_format(self->private_impl.f_pixfmt); wuffs_base__frame_config__set( a_dst, wuffs_base__utility__make_rect_ie_u32( @@ -71740,7 +71767,7 @@ wuffs_qoi__decoder__do_decode_frame_config( 0u, (self->private_impl.f_pixfmt == 2415954056u), false, - 0u); + wuffs_base__pixel_format__default_background_color(&v_pixfmt)); } self->private_impl.f_call_sequence = 64u; @@ -73822,6 +73849,8 @@ wuffs_targa__decoder__do_decode_frame_config( wuffs_base__io_buffer* a_src) { wuffs_base__status status = wuffs_base__make_status(NULL); + wuffs_base__pixel_format v_pixfmt = {0}; + const uint8_t* iop_a_src = NULL; const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; @@ -73864,6 +73893,7 @@ wuffs_targa__decoder__do_decode_frame_config( goto ok; } if (a_dst != NULL) { + v_pixfmt = wuffs_base__utility__make_pixel_format(self->private_impl.f_src_pixfmt); wuffs_base__frame_config__set( a_dst, wuffs_base__utility__make_rect_ie_u32( @@ -73877,7 +73907,7 @@ wuffs_targa__decoder__do_decode_frame_config( 0u, self->private_impl.f_opaque, false, - 4278190080u); + wuffs_base__pixel_format__default_background_color(&v_pixfmt)); } self->private_impl.f_call_sequence = 64u; @@ -75412,6 +75442,8 @@ wuffs_thumbhash__decoder__do_decode_frame_config( wuffs_base__io_buffer* a_src) { wuffs_base__status status = wuffs_base__make_status(NULL); + wuffs_base__pixel_format v_pixfmt = {0}; + const uint8_t* iop_a_src = NULL; const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; @@ -75454,6 +75486,7 @@ wuffs_thumbhash__decoder__do_decode_frame_config( goto ok; } if (a_dst != NULL) { + v_pixfmt = wuffs_base__utility__make_pixel_format(self->private_impl.f_pixfmt); wuffs_base__frame_config__set( a_dst, wuffs_base__utility__make_rect_ie_u32( @@ -75467,7 +75500,7 @@ wuffs_thumbhash__decoder__do_decode_frame_config( 0u, (self->private_impl.f_has_alpha == 0u), false, - 0u); + wuffs_base__pixel_format__default_background_color(&v_pixfmt)); } self->private_impl.f_call_sequence = 64u; @@ -76739,7 +76772,7 @@ wuffs_vp8__decoder__do_decode_frame_config( 0u, false, false, - 0u); + 4278190080u); } self->private_impl.f_call_sequence = 64u; @@ -80855,6 +80888,8 @@ wuffs_webp__decoder__do_decode_frame_config( wuffs_base__io_buffer* a_src) { wuffs_base__status status = wuffs_base__make_status(NULL); + wuffs_base__pixel_format v_pixfmt = {0}; + const uint8_t* iop_a_src = NULL; const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; @@ -80897,6 +80932,7 @@ wuffs_webp__decoder__do_decode_frame_config( goto ok; } if (a_dst != NULL) { + v_pixfmt = wuffs_base__utility__make_pixel_format(self->private_impl.f_pixfmt); wuffs_base__frame_config__set( a_dst, wuffs_base__utility__make_rect_ie_u32( @@ -80910,7 +80946,7 @@ wuffs_webp__decoder__do_decode_frame_config( 0u, false, false, - 0u); + wuffs_base__pixel_format__default_background_color(&v_pixfmt)); } self->private_impl.f_call_sequence = 64u; diff --git a/std/bmp/decode_bmp.wuffs b/std/bmp/decode_bmp.wuffs index 60c06e80..5e65c107 100644 --- a/std/bmp/decode_bmp.wuffs +++ b/std/bmp/decode_bmp.wuffs @@ -417,6 +417,8 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_ } pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) { + var pixfmt : base.pixel_format + if this.call_sequence == 0x20 { // No-op. } else if this.call_sequence < 0x20 { @@ -433,6 +435,7 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base. } if args.dst <> nullptr { + pixfmt = this.util.make_pixel_format(repr: this.src_pixfmt) args.dst.set!(bounds: this.util.make_rect_ie_u32( min_incl_x: 0, min_incl_y: 0, @@ -444,7 +447,7 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base. disposal: 0, opaque_within_bounds: true, overwrite_instead_of_blend: false, - background_color: 0xFF00_0000) + background_color: pixfmt.default_background_color()) } this.call_sequence = 0x40 diff --git a/std/etc2/decode_etc2.wuffs b/std/etc2/decode_etc2.wuffs index d43db3fa..27d241fe 100644 --- a/std/etc2/decode_etc2.wuffs +++ b/std/etc2/decode_etc2.wuffs @@ -164,6 +164,8 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_ } pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) { + var pixfmt : base.pixel_format + if this.call_sequence == 0x20 { // No-op. } else if this.call_sequence < 0x20 { @@ -180,6 +182,7 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base. } if args.dst <> nullptr { + pixfmt = this.util.make_pixel_format(repr: this.pixfmt) args.dst.set!(bounds: this.util.make_rect_ie_u32( min_incl_x: 0, min_incl_y: 0, @@ -191,7 +194,7 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base. disposal: 0, opaque_within_bounds: this.pixfmt == base.PIXEL_FORMAT__BGRX, overwrite_instead_of_blend: false, - background_color: 0xFF00_0000) + background_color: pixfmt.default_background_color()) } this.call_sequence = 0x40 diff --git a/std/netpbm/decode_netpbm.wuffs b/std/netpbm/decode_netpbm.wuffs index 7a546dda..68b53b31 100644 --- a/std/netpbm/decode_netpbm.wuffs +++ b/std/netpbm/decode_netpbm.wuffs @@ -250,7 +250,7 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base. disposal: 0, opaque_within_bounds: false, overwrite_instead_of_blend: false, - background_color: 0x0000_0000) + background_color: 0xFF00_0000) } this.call_sequence = 0x40 diff --git a/std/nie/decode_nie.wuffs b/std/nie/decode_nie.wuffs index ac25ad06..e9481e37 100644 --- a/std/nie/decode_nie.wuffs +++ b/std/nie/decode_nie.wuffs @@ -119,6 +119,8 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_ } pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) { + var pixfmt : base.pixel_format + if this.call_sequence == 0x20 { // No-op. } else if this.call_sequence < 0x20 { @@ -135,6 +137,7 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base. } if args.dst <> nullptr { + pixfmt = this.util.make_pixel_format(repr: this.pixfmt) args.dst.set!(bounds: this.util.make_rect_ie_u32( min_incl_x: 0, min_incl_y: 0, @@ -146,7 +149,7 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base. disposal: 0, opaque_within_bounds: false, overwrite_instead_of_blend: false, - background_color: 0x0000_0000) + background_color: pixfmt.default_background_color()) } this.call_sequence = 0x40 diff --git a/std/png/decode_png.wuffs b/std/png/decode_png.wuffs index c73df24e..0669d50f 100644 --- a/std/png/decode_png.wuffs +++ b/std/png/decode_png.wuffs @@ -966,6 +966,7 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) { var checksum_have : base.u32 + var pixfmt : base.pixel_format if (this.call_sequence & 0x10) <> 0 { return base."#bad call sequence" @@ -1033,6 +1034,7 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base. } if args.dst <> nullptr { + pixfmt = this.util.make_pixel_format(repr: this.src_pixfmt) args.dst.set!(bounds: this.util.make_rect_ie_u32( min_incl_x: this.frame_rect_x0, min_incl_y: this.frame_rect_y0, @@ -1044,7 +1046,7 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base. disposal: this.frame_disposal, opaque_within_bounds: (this.color_type <= 3) and (not this.seen_trns), overwrite_instead_of_blend: this.frame_overwrite_instead_of_blend, - background_color: 0x0000_0000) + background_color: pixfmt.default_background_color()) } this.num_decoded_frame_configs_value ~sat+= 1 diff --git a/std/qoi/decode_qoi.wuffs b/std/qoi/decode_qoi.wuffs index 05d263bb..2dcc7a5b 100644 --- a/std/qoi/decode_qoi.wuffs +++ b/std/qoi/decode_qoi.wuffs @@ -119,6 +119,8 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_ } pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) { + var pixfmt : base.pixel_format + if this.call_sequence == 0x20 { // No-op. } else if this.call_sequence < 0x20 { @@ -135,6 +137,7 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base. } if args.dst <> nullptr { + pixfmt = this.util.make_pixel_format(repr: this.pixfmt) args.dst.set!(bounds: this.util.make_rect_ie_u32( min_incl_x: 0, min_incl_y: 0, @@ -146,7 +149,7 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base. disposal: 0, opaque_within_bounds: this.pixfmt == base.PIXEL_FORMAT__BGRX, overwrite_instead_of_blend: false, - background_color: 0x0000_0000) + background_color: pixfmt.default_background_color()) } this.call_sequence = 0x40 diff --git a/std/targa/decode_targa.wuffs b/std/targa/decode_targa.wuffs index 4e410607..4107f55f 100644 --- a/std/targa/decode_targa.wuffs +++ b/std/targa/decode_targa.wuffs @@ -252,6 +252,8 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_ } pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) { + var pixfmt : base.pixel_format + if this.call_sequence == 0x20 { // No-op. } else if this.call_sequence < 0x20 { @@ -268,6 +270,7 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base. } if args.dst <> nullptr { + pixfmt = this.util.make_pixel_format(repr: this.src_pixfmt) args.dst.set!(bounds: this.util.make_rect_ie_u32( min_incl_x: 0, min_incl_y: 0, @@ -279,7 +282,7 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base. disposal: 0, opaque_within_bounds: this.opaque, overwrite_instead_of_blend: false, - background_color: 0xFF00_0000) + background_color: pixfmt.default_background_color()) } this.call_sequence = 0x40 diff --git a/std/thumbhash/decode_thumbhash.wuffs b/std/thumbhash/decode_thumbhash.wuffs index 487ea1cb..14deb257 100644 --- a/std/thumbhash/decode_thumbhash.wuffs +++ b/std/thumbhash/decode_thumbhash.wuffs @@ -301,6 +301,8 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_ } pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) { + var pixfmt : base.pixel_format + if this.call_sequence == 0x20 { // No-op. } else if this.call_sequence < 0x20 { @@ -317,6 +319,7 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base. } if args.dst <> nullptr { + pixfmt = this.util.make_pixel_format(repr: this.pixfmt) args.dst.set!(bounds: this.util.make_rect_ie_u32( min_incl_x: 0, min_incl_y: 0, @@ -328,7 +331,7 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base. disposal: 0, opaque_within_bounds: this.has_alpha == 0, overwrite_instead_of_blend: false, - background_color: 0x0000_0000) + background_color: pixfmt.default_background_color()) } this.call_sequence = 0x40 diff --git a/std/vp8/decode_vp8.wuffs b/std/vp8/decode_vp8.wuffs index 27151c4d..e804dc05 100644 --- a/std/vp8/decode_vp8.wuffs +++ b/std/vp8/decode_vp8.wuffs @@ -128,7 +128,7 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base. disposal: 0, opaque_within_bounds: false, overwrite_instead_of_blend: false, - background_color: 0x0000_0000) + background_color: 0xFF00_0000) } this.call_sequence = 0x40 diff --git a/std/webp/decode_webp.wuffs b/std/webp/decode_webp.wuffs index 4af5f01d..0589aabf 100644 --- a/std/webp/decode_webp.wuffs +++ b/std/webp/decode_webp.wuffs @@ -308,6 +308,8 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_ } pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) { + var pixfmt : base.pixel_format + if this.call_sequence == 0x20 { // No-op. } else if this.call_sequence < 0x20 { @@ -324,6 +326,7 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base. } if args.dst <> nullptr { + pixfmt = this.util.make_pixel_format(repr: this.pixfmt) args.dst.set!(bounds: this.util.make_rect_ie_u32( min_incl_x: 0, min_incl_y: 0, @@ -335,7 +338,7 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base. disposal: 0, opaque_within_bounds: false, overwrite_instead_of_blend: false, - background_color: 0x0000_0000) + background_color: pixfmt.default_background_color()) } this.call_sequence = 0x40 diff --git a/test/nia-checksums-of-data.txt b/test/nia-checksums-of-data.txt index daf16357..4ec7394b 100644 --- a/test/nia-checksums-of-data.txt +++ b/test/nia-checksums-of-data.txt @@ -106,12 +106,12 @@ OK. dcbb225a test/data/hippopotamus.bmp OK. ed4b78fc test/data/hippopotamus.interlaced.gif OK. dcbb225a test/data/hippopotamus.interlaced.png BAD c3c4bd65 test/data/hippopotamus.interlaced.truncated.gif -BAD 7c6a771b test/data/hippopotamus.interlaced.truncated.png +BAD 3feec847 test/data/hippopotamus.interlaced.truncated.png OK. 96bdbbb3 test/data/hippopotamus.jpeg OK. dcbb225a test/data/hippopotamus.lossless.webp OK. d5577434 test/data/hippopotamus.lossy.webp -OK. 45979d1b test/data/hippopotamus.masked-with-muybridge.etc2.bgra-binary.pkm -OK. b51ed7e8 test/data/hippopotamus.masked-with-muybridge.etc2.bgra-nonpremul.pkm +OK. 2535637e test/data/hippopotamus.masked-with-muybridge.etc2.bgra-binary.pkm +OK. 720180ee test/data/hippopotamus.masked-with-muybridge.etc2.bgra-nonpremul.pkm OK. d3bbed27 test/data/hippopotamus.masked-with-muybridge.gif OK. 7e6acf01 test/data/hippopotamus.masked-with-muybridge.png OK. dcbb225a test/data/hippopotamus.nie @@ -119,7 +119,7 @@ OK. 57d9a4dd test/data/hippopotamus.pgm OK. dcbb225a test/data/hippopotamus.ppm OK. ed4b78fc test/data/hippopotamus.regular.gif OK. dcbb225a test/data/hippopotamus.regular.png -BAD 888b1c04 test/data/hippopotamus.regular.truncated.png +BAD e4c5926b test/data/hippopotamus.regular.truncated.png OK. f6bb81e2 test/data/mona-lisa.21x32.etc2.pkm OK. 012ce4cf test/data/mona-lisa.21x32.png OK. 0a22e689 test/data/mona-lisa.21x32.q50.jpeg