std/png: decode PNG color type 4 to YA_NONPREMUL

Fixes #143
This commit is contained in:
Nigel Tao committed 2024-03-27 21:06:09 +11:00
1 parent bdfbdf407e
commit b4cd9b8d3c
3 files changed
+6 -31

No files matched your search

+2 -3
View File
@@ -455,10 +455,9 @@ pri func decoder.assign_filter_distance!() {
} else if this.color_type == 4 {
if this.depth == 8 {
this.dst_pixfmt = base.PIXEL_FORMAT__BGRA_NONPREMUL
this.src_pixfmt = base.PIXEL_FORMAT__BGRA_NONPREMUL
this.dst_pixfmt = base.PIXEL_FORMAT__YA_NONPREMUL
this.src_pixfmt = base.PIXEL_FORMAT__YA_NONPREMUL
this.filter_distance = 2
choose filter_and_swizzle = [filter_and_swizzle_tricky]
} else if this.depth == 16 {
this.dst_pixfmt = base.PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE
this.src_pixfmt = base.PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE
+1 -14
View File
@@ -101,20 +101,7 @@ pri func decoder.filter_and_swizzle_tricky!(dst: ptr base.pixel_buffer, workbuf:
assert x < 0x00FF_FFFF via "a < b: a < c; c <= b"(c: this.frame_rect_x1)
i = (x as base.u64) * dst_bytes_per_pixel
if i <= dst.length() {
if this.color_type == 4 {
if 2 <= s.length() {
bits_unpacked[0] = s[0]
bits_unpacked[1] = s[0]
bits_unpacked[2] = s[0]
bits_unpacked[3] = s[1]
s = s[2 ..]
this.swizzler.swizzle_interleaved_from_slice!(
dst: dst[i ..],
dst_palette: dst_palette,
src: bits_unpacked[.. 4])
}
} else if ((this.remap_transparency & 0xFFFF_FFFF) as base.u32) <> 0 {
if ((this.remap_transparency & 0xFFFF_FFFF) as base.u32) <> 0 {
if this.color_type == 0 {
if 1 <= s.length() {
bits_unpacked[0] = s[0]