papermario/tools/n64splat/util/color.py
Ethan Roseman 5e12a46dd4 git subrepo clone (merge) https://github.com/ethteck/n64splat.git tools/n64splat
subrepo:
  subdir:   "tools/n64splat"
  merged:   "7574db712"
upstream:
  origin:   "https://github.com/ethteck/n64splat.git"
  branch:   "master"
  commit:   "7574db712"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"
2021-01-15 10:26:06 +09:00

17 lines
333 B
Python

from math import ceil
# RRRRRGGG GGBBBBBA
def unpack_color(data):
s = int.from_bytes(data[0:2], byteorder="big")
r = (s >> 11) & 0x1F
g = (s >> 6) & 0x1F
b = (s >> 1) & 0x1F
a = (s & 1) * 0xFF
r = ceil(0xFF * (r / 31))
g = ceil(0xFF * (g / 31))
b = ceil(0xFF * (b / 31))
return r, g, b, a