#!/usr/bin/env python3 """Generate a C++ header that embeds an image file as a byte array. Usage: icon_to_header.py INPUT_IMAGE OUTPUT_HEADER """ import sys def main() -> int: if len(sys.argv) != 3: print(f"usage: {sys.argv[0]} INPUT_IMAGE OUTPUT_HEADER", file=sys.stderr) return 2 with open(sys.argv[1], "rb") as src: data = src.read() words = ", ".join(f"0x{byte:02x}" for byte in data) header = f"""// GENERATED FILE - do not edit by hand. // Produced by scripts/icon_to_header.py from screencast_icon/screencast_256.png. #pragma once #include #include namespace sc {{ inline constexpr std::array app_icon_png = {{ {words} }}; }} // namespace sc """ with open(sys.argv[2], "w") as dst: dst.write(header) return 0 if __name__ == "__main__": sys.exit(main())