This commit is contained in:
gingerBill
2021-05-01 17:30:27 +01:00
2 changed files with 16 additions and 19 deletions
+16 -18
View File
@@ -1049,28 +1049,25 @@ load_from_stream :: proc(stream: io.Stream, options := Options{}, allocator := c
} }
for len(p) > 0 { for len(p) > 0 {
r := p[0]; r := p[0];
alpha := u8(1); alpha := u8(1);
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[1] = r;
o[2] = r;
} }
o[0] = r;
o[1] = 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,17 +1145,17 @@ 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[1] = g;
o[2] = b;
} }
o[0] = r;
o[1] = g;
o[2] = b;
if out_image_channels == 4 { if out_image_channels == 4 {
o[3] = alpha * 255; o[3] = alpha * 255;
} }
-1
View File
@@ -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) {