fix image building to work with new n64img output (#1001)

This commit is contained in:
Marijn van der Werf 2023-03-26 17:43:00 +02:00 committed by GitHub
parent accdc4a7f6
commit 0c741974a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,16 +18,12 @@ def unpack_color(s):
return r, g, b, a
def pack_color(r, g, b, a):
r = floor(31 * (r / 255))
g = floor(31 * (g / 255))
b = floor(31 * (b / 255))
r = r >> 3
g = g >> 3
b = b >> 3
a = a >> 7
s = round(a / 0xFF)
s |= (r & 0x1F) << 11
s |= (g & 0x1F) << 6
s |= (b & 0x1F) << 1
return s
return (r << 11) | (g << 6) | (b << 1) | a
def rgb_to_intensity(r, g, b):
return round(r * 0.2126 + g * 0.7152 + 0.0722 * b)
@ -110,8 +106,8 @@ class Converter():
i2 = rgb_to_intensity(*c2[:3])
a2 = c2[3]
i1 = floor(7 * (i1 / 0xFF))
i2 = floor(7 * (i2 / 0xFF))
i1 = i1 >> 5
i2 = i2 >> 5
if a1 not in (0, 0xFF) or a2 not in (0, 0xFF):
self.warn("alpha mask mode but translucent pixels used")