mirror of
https://github.com/kbeckmann/game-and-watch-retro-go.git
synced 2025-12-16 13:15:55 +01:00
* draw_darken_rounded_rectangle initial commit * image drawing routines * mostly working static overlay * use 24x24 instead of 32x32 images, slightly tweak some layout * complete volume and brightness overlays * save/load overlay * png icons and tool to convert them to bit arrays * add speedup overlay icons * install common_ingame_overlay hook to all emulators * explicitly invoke ingame overlay when saving so that the icon shows up before the pause * make transparency look a little better on dark backgrounds * tweak bars offset * have pce use lcd_get_active_framebuffer * shift sun 1 pixel to the right; even though it's just as off-centered, it looks better
43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
import argparse
|
|
from pathlib import Path
|
|
|
|
import imageio
|
|
import numpy as np
|
|
|
|
|
|
def parse_args():
|
|
"""Parse CLI arguments into an object and a dictionary"""
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("png", type=Path)
|
|
parser.add_argument("--invert", action="store_true")
|
|
args = parser.parse_args()
|
|
return args
|
|
|
|
|
|
def main():
|
|
args = parse_args()
|
|
img = imageio.imread(args.png)
|
|
if img.ndim == 3:
|
|
if img.shape[-1] == 4:
|
|
img = (img == [0, 0, 0, 255]).all(axis=-1)
|
|
img = ~img
|
|
else:
|
|
raise NotImplementedError
|
|
img = img.astype(bool)
|
|
if args.invert:
|
|
img = ~img
|
|
print(f"// img shape: {img.shape}")
|
|
img_packed = np.packbits(img)
|
|
print("static const uint8_t img[] = {")
|
|
for i in range(0, len(img_packed), 8):
|
|
print(
|
|
f" 0x{img_packed[i]:02X}, 0x{img_packed[i+1]:02X}, 0x{img_packed[i+2]:02X}, "
|
|
f"0x{img_packed[i+3]:02X}, 0x{img_packed[i+4]:02X}, 0x{img_packed[i+5]:02X}, "
|
|
f"0x{img_packed[i+6]:02X}, 0x{img_packed[i+7]:02X},"
|
|
)
|
|
print("};")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|