mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-13 09:44:31 -05:00
LupusE's patch (#2300)
* LupusE's commit * fix f obj doesn't exist --------- Co-authored-by: zxkmm <zxkmm@hotmail.com>
This commit is contained in:
parent
26b830b816
commit
e01a184721
@ -24,25 +24,26 @@ from PIL import Image
|
|||||||
from os import listdir
|
from os import listdir
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
usage_message = """
|
usage_message = f"""
|
||||||
1BPP PortaPack bitmap.hpp generator
|
1BPP PortaPack bitmap.hpp generator
|
||||||
|
|
||||||
Usage: <directory>
|
Usage: {sys.argv[0]} <directory>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
print(usage_message)
|
print(usage_message)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
|
graphics_path = path.join(sys.argv[1], '')
|
||||||
|
|
||||||
def convert_png(file):
|
def convert_png(file):
|
||||||
c = 0
|
c = 0
|
||||||
data = 0
|
data = 0
|
||||||
|
|
||||||
im = Image.open(file)
|
rgb_im = Image.open(file).convert('RGBA')
|
||||||
rgb_im = im.convert('RGBA')
|
|
||||||
|
|
||||||
if rgb_im.size[0] % 8 or rgb_im.size[1] % 8:
|
if rgb_im.size[0] % 8 or rgb_im.size[1] % 8:
|
||||||
print((file + ": Size isn\'t a multiple of 8"))
|
print((file + ": Size is not a multiple of 8. Image is not included in bitmap.hpp."))
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
name = path.basename(file).split(".")[0].lower();
|
name = path.basename(file).split(".")[0].lower();
|
||||||
@ -70,36 +71,36 @@ def convert_png(file):
|
|||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
f = open('bitmap.hpp', 'w')
|
f = open('bitmap.hpp', 'w')
|
||||||
f.write("/*\n")
|
f.write("/*\n"
|
||||||
f.write(" * Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.\n")
|
" * Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.\n"
|
||||||
f.write(" * Copyright (C) 2016 Furrtek\n")
|
" * Copyright (C) 2016 Furrtek\n"
|
||||||
f.write(" *\n")
|
" *\n"
|
||||||
f.write(" * This file is part of PortaPack.\n")
|
" * This file is part of PortaPack.\n"
|
||||||
f.write(" *\n")
|
" *\n"
|
||||||
f.write(" * This program is free software; you can redistribute it and/or modify\n")
|
" * This program is free software; you can redistribute it and/or modify\n"
|
||||||
f.write(" * it under the terms of the GNU General Public License as published by\n")
|
" * it under the terms of the GNU General Public License as published by\n"
|
||||||
f.write(" * the Free Software Foundation; either version 2, or (at your option)\n")
|
" * the Free Software Foundation; either version 2, or (at your option)\n"
|
||||||
f.write(" * any later version.\n")
|
" * any later version.\n"
|
||||||
f.write(" *\n")
|
" *\n"
|
||||||
f.write(" * This program is distributed in the hope that it will be useful,\n")
|
" * This program is distributed in the hope that it will be useful,\n"
|
||||||
f.write(" * but WITHOUT ANY WARRANTY; without even the implied warranty of\n")
|
" * but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
||||||
f.write(" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n")
|
" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
||||||
f.write(" * GNU General Public License for more details.\n")
|
" * GNU General Public License for more details.\n"
|
||||||
f.write(" *\n")
|
" *\n"
|
||||||
f.write(" * You should have received a copy of the GNU General Public License\n")
|
" * You should have received a copy of the GNU General Public License\n"
|
||||||
f.write(" * along with this program; see the file COPYING. If not, write to\n")
|
" * along with this program; see the file COPYING. If not, write to\n"
|
||||||
f.write(" * the Free Software Foundation, Inc., 51 Franklin Street,\n")
|
" * the Free Software Foundation, Inc., 51 Franklin Street,\n"
|
||||||
f.write(" * Boston, MA 02110-1301, USA.\n")
|
" * Boston, MA 02110-1301, USA.\n"
|
||||||
f.write(" */\n\n")
|
" */\n\n"
|
||||||
f.write("// This file was generated by make_bitmap.py\n\n")
|
"// This file was generated by make_bitmap.py\n\n"
|
||||||
f.write("#ifndef __BITMAP_HPP__\n")
|
"#ifndef __BITMAP_HPP__\n"
|
||||||
f.write("#define __BITMAP_HPP__\n\n")
|
"#define __BITMAP_HPP__\n\n"
|
||||||
f.write("#include \"ui.hpp\"\n\n")
|
"#include \"ui.hpp\"\n\n"
|
||||||
f.write("namespace ui {\n\n")
|
"namespace ui {\n\n")
|
||||||
|
|
||||||
for file in listdir(sys.argv[1]):
|
for file in listdir(graphics_path):
|
||||||
if file.endswith(".png"):
|
if file.endswith(".png") and path.isfile(graphics_path + file):
|
||||||
convert_png(sys.argv[1] + file)
|
convert_png(graphics_path + file)
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
f.write("} /* namespace ui */\n\n")
|
f.write("} /* namespace ui */\n\n")
|
||||||
|
2
hackrf
2
hackrf
@ -1 +1 @@
|
|||||||
Subproject commit d4ed8474e532ccdbf605ee71c0f1fa0557da19e1
|
Subproject commit 22c9ff10f934695065b6f79f4d95b812b0ab8365
|
Loading…
Reference in New Issue
Block a user