mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
PNG: Fix tRNS handling.
This commit is contained in:
+11
-13
@@ -1055,22 +1055,19 @@ load_from_stream :: proc(stream: io.Stream, options := Options{}, allocator := c
|
|||||||
if seen_trns {
|
if seen_trns {
|
||||||
if r == key {
|
if r == key {
|
||||||
if seen_bkgd {
|
if seen_bkgd {
|
||||||
c := img.background.([3]u16);
|
bc := img.background.([3]u16);
|
||||||
r = u8(c[0]);
|
r = u8(bc[0]);
|
||||||
} else {
|
} else {
|
||||||
alpha = 0; // Keyed transparency
|
alpha = 0; // Keyed transparency
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if premultiply {
|
if premultiply {
|
||||||
o[0] = r * alpha;
|
r *= alpha;
|
||||||
o[1] = r * alpha;
|
}
|
||||||
o[2] = r * alpha;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
o[0] = r;
|
o[0] = r;
|
||||||
o[1] = r;
|
o[1] = r;
|
||||||
o[2] = r;
|
o[2] = r;
|
||||||
}
|
|
||||||
|
|
||||||
if out_image_channels == 4 {
|
if out_image_channels == 4 {
|
||||||
o[3] = alpha * 255;
|
o[3] = alpha * 255;
|
||||||
@@ -1128,6 +1125,7 @@ load_from_stream :: proc(stream: io.Stream, options := Options{}, allocator := c
|
|||||||
*/
|
*/
|
||||||
key = []u8{trns.data[1], trns.data[3], trns.data[5]};
|
key = []u8{trns.data[1], trns.data[3], trns.data[5]};
|
||||||
}
|
}
|
||||||
|
|
||||||
for len(p) > 0 {
|
for len(p) > 0 {
|
||||||
r := p[0];
|
r := p[0];
|
||||||
g := p[1];
|
g := p[1];
|
||||||
@@ -1147,16 +1145,16 @@ load_from_stream :: proc(stream: io.Stream, options := Options{}, allocator := c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if .alpha_premultiply in options || .blend_background in options {
|
if premultiply {
|
||||||
o[0] = r * alpha;
|
r *= alpha;
|
||||||
o[1] = g * alpha;
|
g *= alpha;
|
||||||
o[2] = b * alpha;
|
b *= alpha;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
o[0] = r;
|
o[0] = r;
|
||||||
o[1] = g;
|
o[1] = g;
|
||||||
o[2] = b;
|
o[2] = b;
|
||||||
}
|
|
||||||
|
|
||||||
if out_image_channels == 4 {
|
if out_image_channels == 4 {
|
||||||
o[3] = alpha * 255;
|
o[3] = alpha * 255;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package testing
|
|||||||
|
|
||||||
import "core:io"
|
import "core:io"
|
||||||
import "core:os"
|
import "core:os"
|
||||||
import "core:strings"
|
|
||||||
import "core:slice"
|
import "core:slice"
|
||||||
|
|
||||||
reset_t :: proc(t: ^T) {
|
reset_t :: proc(t: ^T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user