From 8463cba4b6b2d36bc319bc9666a8333c5d78a591 Mon Sep 17 00:00:00 2001 From: dqs105 Date: Fri, 28 Aug 2020 00:22:36 +0800 Subject: [PATCH] Splash generator. (Modified from the one generates world_map.bin) --- firmware/tools/generate_custom_splash.py | 65 ++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 firmware/tools/generate_custom_splash.py diff --git a/firmware/tools/generate_custom_splash.py b/firmware/tools/generate_custom_splash.py new file mode 100644 index 00000000..b6bff021 --- /dev/null +++ b/firmware/tools/generate_custom_splash.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +# Copyright (C) 2017 Furrtek +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from __future__ import print_function +import sys +import struct +from PIL import Image + +usage_info = """ +Custom splash generator + +Usage: + + Notice: + Input image size should be 304x240. + Generated image will be named "splash.bin", put it under SD card's root directory will work. +""" + +if len(sys.argv) != 2: + print(usage_info) + sys.exit(-1) + +outfile = open("splash.bin", 'wb') + +# Allow for bigger images +Image.MAX_IMAGE_PIXELS = None +im = Image.open(sys.argv[1]) +pix = im.load() + +outfile.write(bytes("RAW\x00")) +outfile.write(struct.pack('H', im.size[1])) +outfile.write(struct.pack('H', im.size[0])) + +for y in range (0, im.size[1]): + line = '' + for x in range (0, im.size[0]): + # RRRRRGGGGGGBBBBB + pixel_lcd = (pix[x, y][0] >> 3) << 11 + pixel_lcd |= (pix[x, y][1] >> 2) << 5 + pixel_lcd |= (pix[x, y][2] >> 3) + # RRRGGGBB to + # RRR00GGG000BB000 + # pixel_lcd = (pix[x, y][0] >> 5) << 5 + # pixel_lcd |= (pix[x, y][1] >> 5) << 2 + # pixel_lcd |= (pix[x, y][2] >> 6) + line += struct.pack('H', pixel_lcd) + outfile.write(line) + print(str(y) + '/' + str(im.size[1]) + '\r', end="")