| 123456789101112131415161718192021222324 |
- # Generates src/ui/SplashData.h: the pepper from resources/lynx_logo.png, cropped and scaled for the splash screen.
- # Usage: python3 tools/make_splash.py (from the repository root)
- import io
- from PIL import Image
- HEIGHT = 420 # px: sharp up to 175% display scaling at the splash's drawn size
- pepper = Image.open("resources/lynx_logo.png").convert("RGBA")
- pepper = pepper.crop(pepper.getbbox())
- width = round(pepper.width * HEIGHT / pepper.height)
- pepper = pepper.resize((width, HEIGHT), Image.LANCZOS)
- out = io.BytesIO()
- pepper.save(out, "PNG", optimize=True)
- data = out.getvalue()
- lines = ["#pragma once", "",
- "// The pepper for the splash screen (resources/lynx_logo.png cropped to its outline, %dx%d PNG with transparency)." % (width, HEIGHT),
- "// Generated by tools/make_splash.py - do not edit by hand.", "",
- "namespace lynx::splashdata", "{", "inline constexpr unsigned char pepperPng[] = {"]
- for i in range(0, len(data), 24):
- lines.append(", ".join(str(b) for b in data[i:i + 24]) + ",")
- lines += ["};", "} // namespace lynx::splashdata", ""]
- open("src/ui/SplashData.h", "w").write("\n".join(lines))
- print(width, HEIGHT, len(data), "bytes")
|