draw_image o ili

demo file
This commit is contained in:
Bartosz Kościów 2017-04-28 19:32:09 +02:00
parent 17d540bf15
commit 465e14c972
7 changed files with 41 additions and 2 deletions

View File

@ -99,3 +99,8 @@ class Chip(metaclass=abc.ABCMeta):
def fill_rect(self, pos_x1, pos_y1, pos_x2, pos_y2):
"""draw a filled rectangle"""
pass
@abc.abstractmethod
def draw_image(self, pos_x, pos_y, image):
"""draw a PIL image"""
pass

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

20
gfxlcd/demos/ili_image.py Normal file
View File

@ -0,0 +1,20 @@
import RPi.GPIO
import sys
sys.path.append("../../")
from gfxlcd.driver.ili9325.gpio import GPIO as ILIGPIO
from gfxlcd.driver.ili9325.ili9325 import ILI9325
RPi.GPIO.setmode(RPi.GPIO.BCM)
from PIL import Image
lcd_tft = ILI9325(240, 320, ILIGPIO())
lcd_tft.init()
# bypass of missing +3v line to power backlight
LED = 6
RPi.GPIO.setup(LED, RPi.GPIO.OUT)
RPi.GPIO.output(LED, 1)
image_file = Image.open("japan_temple_240x320.jpg")
image_file = image_file.convert('RGB')
lcd_tft.draw_image(0, 0, image_file)

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -121,3 +121,17 @@ class Area(Pixel):
color = self._converted_background_color()
for _ in range(0, size):
self.driver.data(color, None)
def draw_image(self, pos_x, pos_y, image):
"""draw a PIL image"""
image_file = image.convert('RGB')
width, height = image_file.size
self._set_area(
pos_x,
pos_y,
pos_x + width - 1,
pos_y + height - 1
)
for r, g, b in list(image_file.getdata()):
self.color = (r, g, b)
self.driver.data(self._converted_color(), None)

View File

@ -13,11 +13,11 @@ def read(*paths):
setup(
name='gfxlcd',
version='0.1.0',
version='0.1.2',
description='gfxlcd is a handler for grpahical lcds: ILI9328, SSD1306, NJU6450 @ Raspberry Pi.',
keywords=['gfxlcd', 'raspberry pi' ,'ili9328' ,'ssd1306', 'nju6450', 'lcd', 'graphical lcd'],
long_description=(read('readme.md')),
url='https://bitbucket.org/kosci/charlcd.git',
url='https://github.com/bkosciow/gfxlcd',
license='MIT',
author='Bartosz Kościów',
author_email='kosci1@gmail.com',