diff --git a/CHANGELOG.txt b/CHANGELOG.txt index b1856b7..09694b3 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,5 @@ +0.8.3 + - draw_image with filename or PIL object 0.8.2 - fix background colour in Page drawing 0.8.1 diff --git a/gfxlcd/demos/ili9325_image.py b/gfxlcd/demos/ili9325_image.py index 7c58fc6..e63426a 100644 --- a/gfxlcd/demos/ili9325_image.py +++ b/gfxlcd/demos/ili9325_image.py @@ -14,9 +14,10 @@ lcd_tft = ILI9325(240, 320, drv) lcd_tft.init() -image_file = Image.open("assets/japan_temple_240x320.jpg") -lcd_tft.draw_image(0, 0, image_file) +# image_file = Image.open("assets/japan_temple_240x320.jpg") +# lcd_tft.draw_image(0, 0, image_file) -numbers_image = Image.open("assets/dsp2017_101_64.png") +# numbers_image = Image.open("assets/dsp2017_101_64.png") lcd_tft.transparency_color = (0, 0, 0) -lcd_tft.draw_image(10, 10, numbers_image) +# lcd_tft.draw_image(10, 10, numbers_image) +lcd_tft.draw_image(10, 10, "assets/dsp2017_101_64.png") diff --git a/gfxlcd/drawing/area.py b/gfxlcd/drawing/area.py index a8ff163..fbdaa47 100644 --- a/gfxlcd/drawing/area.py +++ b/gfxlcd/drawing/area.py @@ -1,6 +1,7 @@ """Area drawing algorithm""" import itertools from gfxlcd.drawing.pixel import Pixel +from PIL import Image class Area(Pixel): @@ -103,6 +104,8 @@ class Area(Pixel): def draw_image(self, pos_x, pos_y, image): """draw a PIL image""" + if isinstance(image, str): + image = Image.open(image) image_file = image.convert('RGB') width, height = image_file.size self._set_area( diff --git a/gfxlcd/drawing/page.py b/gfxlcd/drawing/page.py index d304930..6e842c8 100644 --- a/gfxlcd/drawing/page.py +++ b/gfxlcd/drawing/page.py @@ -1,6 +1,7 @@ """Page drawing algorithm""" import abc from gfxlcd.drawing.pixel import Pixel +from PIL import Image class Page(Pixel, metaclass=abc.ABCMeta): @@ -126,6 +127,8 @@ class Page(Pixel, metaclass=abc.ABCMeta): def draw_image(self, pos_x, pos_y, image): """draw a PIL image""" + if isinstance(image, str): + image = Image.open(image) image_file = image.convert('L') width, height = image_file.size offset_x = 0 diff --git a/setup.py b/setup.py index a1f2689..278d9e9 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ def read(*paths): setup( name='gfxlcd', - version='0.8.2', + version='0.8.3', description='gfxlcd is a handler for graphical lcds: ILI9328, SSD1306, NJU6450, touch panel: AD7843 @ Raspberry Pi.', keywords=[ 'gfxlcd', 'raspberry pi' ,'ili9328' ,'ssd1306', 'nju6450', 'lcd', 'graphical lcd', 'touch panel', 'ad7843',