mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 16:55:11 +01:00
Let std/png allow PLTE for RGB, RGBA color types
This commit is contained in:
1 parent
cdf3bbfb26
commit
a684928240
3 files changed
+29
-14
No files matched your search
@@ -37927,20 +37927,25 @@ wuffs_png__decoder__decode_other_chunk(
|
|||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||||
|
|
||||||
if (self->private_impl.f_chunk_type == 1163152464) {
|
if (self->private_impl.f_chunk_type == 1163152464) {
|
||||||
if (self->private_impl.f_seen_plte || (self->private_impl.f_color_type != 3)) {
|
if (self->private_impl.f_seen_plte) {
|
||||||
|
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||||
|
goto exit;
|
||||||
|
} else if (self->private_impl.f_color_type == 3) {
|
||||||
|
if (a_src) {
|
||||||
|
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||||
|
}
|
||||||
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||||
|
status = wuffs_png__decoder__decode_plte(self, a_src);
|
||||||
|
if (a_src) {
|
||||||
|
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||||
|
}
|
||||||
|
if (status.repr) {
|
||||||
|
goto suspend;
|
||||||
|
}
|
||||||
|
} else if ((self->private_impl.f_color_type == 2) || (self->private_impl.f_color_type == 6)) {
|
||||||
|
} else {
|
||||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
|
||||||
if (a_src) {
|
|
||||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
|
||||||
}
|
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
|
||||||
status = wuffs_png__decoder__decode_plte(self, a_src);
|
|
||||||
if (a_src) {
|
|
||||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
|
||||||
}
|
|
||||||
if (status.repr) {
|
|
||||||
goto suspend;
|
|
||||||
}
|
}
|
||||||
self->private_impl.f_seen_plte = true;
|
self->private_impl.f_seen_plte = true;
|
||||||
} else if ((self->private_impl.f_chunk_type & 32) == 0) {
|
} else if ((self->private_impl.f_chunk_type & 32) == 0) {
|
||||||
|
|||||||
@@ -535,10 +535,18 @@ pri func decoder.choose_filter_implementations!() {
|
|||||||
|
|
||||||
pri func decoder.decode_other_chunk?(src: base.io_reader) {
|
pri func decoder.decode_other_chunk?(src: base.io_reader) {
|
||||||
if this.chunk_type == 'PLTE'le {
|
if this.chunk_type == 'PLTE'le {
|
||||||
if this.seen_plte or (this.color_type <> 3) {
|
if this.seen_plte {
|
||||||
|
return "#bad chunk"
|
||||||
|
} else if this.color_type == 3 {
|
||||||
|
// Color type 3 means paletted.
|
||||||
|
this.decode_plte?(src: args.src)
|
||||||
|
} else if (this.color_type == 2) or (this.color_type == 6) {
|
||||||
|
// Color types 2 and 6 means RGB and RGBA. In these cases, the PLTE
|
||||||
|
// chunk is merely a hint, like a sPLT "suggested palette" chunk.
|
||||||
|
// We ignore it.
|
||||||
|
} else {
|
||||||
return "#bad chunk"
|
return "#bad chunk"
|
||||||
}
|
}
|
||||||
this.decode_plte?(src: args.src)
|
|
||||||
this.seen_plte = true
|
this.seen_plte = true
|
||||||
|
|
||||||
} else if (this.chunk_type & ANCILLARY_BIT) == 0 {
|
} else if (this.chunk_type & ANCILLARY_BIT) == 0 {
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ bb956205 test/3pdata/pngsuite/oi4n0g16.png
|
|||||||
84bc9be8 test/3pdata/pngsuite/oi4n2c16.png
|
84bc9be8 test/3pdata/pngsuite/oi4n2c16.png
|
||||||
bb956205 test/3pdata/pngsuite/oi9n0g16.png
|
bb956205 test/3pdata/pngsuite/oi9n0g16.png
|
||||||
84bc9be8 test/3pdata/pngsuite/oi9n2c16.png
|
84bc9be8 test/3pdata/pngsuite/oi9n2c16.png
|
||||||
|
84bc9be8 test/3pdata/pngsuite/pp0n2c16.png
|
||||||
|
91dbb0d0 test/3pdata/pngsuite/pp0n6a08.png
|
||||||
024cf410 test/3pdata/pngsuite/ps1n0g08.png
|
024cf410 test/3pdata/pngsuite/ps1n0g08.png
|
||||||
84bc9be8 test/3pdata/pngsuite/ps1n2c16.png
|
84bc9be8 test/3pdata/pngsuite/ps1n2c16.png
|
||||||
024cf410 test/3pdata/pngsuite/ps2n0g08.png
|
024cf410 test/3pdata/pngsuite/ps2n0g08.png
|
||||||
|
|||||||
Reference in new issue
Block a user