mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 16:55:11 +01:00
std/png: ignore tRNS chunks for color types 4, 6
This backports commit da0d51d802 from the
main branch (working on an unstable v0.4) to the v0.3 branch.
Updates #146
This commit is contained in:
1 parent
d910658bce
commit
a138188d57
3 files changed
+30
-14
No files matched your search
@@ -1,6 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
|
||||||
|
## 2024-04-19 version 0.3.4
|
||||||
|
|
||||||
|
- Have `std/png` ignore tRNS chunks for color types 4 (YA) and 6 (RGBA).
|
||||||
|
|
||||||
|
|
||||||
## 2023-04-08 version 0.3.3
|
## 2023-04-08 version 0.3.3
|
||||||
|
|
||||||
The `wuffs_base__parse_number_f64` function has been further optimized.
|
The `wuffs_base__parse_number_f64` function has been further optimized.
|
||||||
|
|||||||
@@ -41568,20 +41568,22 @@ wuffs_png__decoder__decode_other_chunk(
|
|||||||
self->private_impl.f_seen_srgb = true;
|
self->private_impl.f_seen_srgb = true;
|
||||||
}
|
}
|
||||||
} else if (self->private_impl.f_chunk_type == 1397641844) {
|
} else if (self->private_impl.f_chunk_type == 1397641844) {
|
||||||
if (self->private_impl.f_seen_trns || (self->private_impl.f_color_type > 3) || ((self->private_impl.f_color_type == 3) && ! self->private_impl.f_seen_plte)) {
|
if (self->private_impl.f_seen_trns || ((self->private_impl.f_color_type == 3) && ! self->private_impl.f_seen_plte)) {
|
||||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
} else if (self->private_impl.f_color_type > 3) {
|
||||||
if (a_src) {
|
} else {
|
||||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
if (a_src) {
|
||||||
}
|
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9);
|
}
|
||||||
status = wuffs_png__decoder__decode_trns(self, a_src);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9);
|
||||||
if (a_src) {
|
status = wuffs_png__decoder__decode_trns(self, a_src);
|
||||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
if (a_src) {
|
||||||
}
|
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||||
if (status.repr) {
|
}
|
||||||
goto suspend;
|
if (status.repr) {
|
||||||
|
goto suspend;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self->private_impl.f_seen_trns = true;
|
self->private_impl.f_seen_trns = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -615,11 +615,20 @@ pri func decoder.decode_other_chunk?(src: base.io_reader, framy: base.bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if this.chunk_type == 'tRNS'le {
|
} else if this.chunk_type == 'tRNS'le {
|
||||||
if this.seen_trns or (this.color_type > 3) or
|
if this.seen_trns or
|
||||||
((this.color_type == 3) and (not this.seen_plte)) {
|
((this.color_type == 3) and (not this.seen_plte)) {
|
||||||
return "#bad chunk"
|
return "#bad chunk"
|
||||||
|
} else if this.color_type > 3 {
|
||||||
|
// No-op, ignoring the chunk. The PNG spec section "11.3.2.1
|
||||||
|
// tRNS Transparency" says that "A tRNS chunk shall not appear
|
||||||
|
// for colour types 4 and 6, since a full alpha channel is
|
||||||
|
// already present in those cases." However, some real-world
|
||||||
|
// PNG images (incorrectly) have these. libpng treats this as a
|
||||||
|
// "benign error", not a fatal one. See
|
||||||
|
// https://github.com/google/wuffs/issues/146
|
||||||
|
} else {
|
||||||
|
this.decode_trns?(src: args.src)
|
||||||
}
|
}
|
||||||
this.decode_trns?(src: args.src)
|
|
||||||
this.seen_trns = true
|
this.seen_trns = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user