2018-05-15 18:35:30 -04:00
|
|
|
#!/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
|
|
|
|
|
2020-08-25 19:40:51 -04:00
|
|
|
outfile = open('../../sdcard/ADSB/world_map.bin', 'wb')
|
2018-05-15 18:35:30 -04:00
|
|
|
|
2020-05-02 05:42:36 -04:00
|
|
|
# Allow for bigger images
|
2020-05-05 06:42:40 -04:00
|
|
|
Image.MAX_IMAGE_PIXELS = None
|
2020-05-10 10:55:27 -04:00
|
|
|
im = Image.open("../../sdcard/ADSB/world_map.jpg")
|
2018-05-15 18:35:30 -04:00
|
|
|
pix = im.load()
|
|
|
|
|
|
|
|
outfile.write(struct.pack('H', im.size[0]))
|
|
|
|
outfile.write(struct.pack('H', im.size[1]))
|
|
|
|
|
2020-10-24 16:38:43 -04:00
|
|
|
print("Generating: \t" + outfile.name + "\n from\t\t" + im.filename + "\n please wait...");
|
|
|
|
|
2018-05-15 18:35:30 -04:00
|
|
|
for y in range (0, im.size[1]):
|
|
|
|
line = ''
|
|
|
|
for x in range (0, im.size[0]):
|
|
|
|
# RRRRRGGGGGGBBBBB
|
2020-05-02 05:42:36 -04:00
|
|
|
pixel_lcd = (pix[x, y][0] >> 3) << 11
|
|
|
|
pixel_lcd |= (pix[x, y][1] >> 2) << 5
|
|
|
|
pixel_lcd |= (pix[x, y][2] >> 3)
|
2018-05-15 18:35:30 -04:00
|
|
|
# RRRGGGBB to
|
|
|
|
# RRR00GGG000BB000
|
2020-05-02 05:42:36 -04:00
|
|
|
# pixel_lcd = (pix[x, y][0] >> 5) << 5
|
|
|
|
# pixel_lcd |= (pix[x, y][1] >> 5) << 2
|
|
|
|
# pixel_lcd |= (pix[x, y][2] >> 6)
|
2020-10-24 16:38:43 -04:00
|
|
|
line += str(struct.pack('H', pixel_lcd))
|
|
|
|
outfile.write(line.encode('utf-8'))
|
2018-05-15 18:35:30 -04:00
|
|
|
print(str(y) + '/' + str(im.size[1]) + '\r', end="")
|
2020-10-24 16:38:43 -04:00
|
|
|
|
|
|
|
print("Ready.");
|