5 examples of 'python display image on screen' in Python

Every line of 'python display image on screen' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
215def display_image(lcd_screen, image):
216 """
217 Helper function to put an image on the screen. All images used with this function should be full screen images.
218 The screen is 178 by 128 pixels. In this module we're using ones that came from Lego that are full screen.
219 Smaller images can be used as well and the upper left corner does not always need to be 0, 0.
220
221 Type hints:
222 :type lcd_screen: ev3.Screen
223 :type image: Image
224 """
225 lcd_screen.image.paste(image, (0, 0))
226 lcd_screen.update()
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

68def display(self, image):
69 """
70 Renders a 24-bit RGB image to the Color OLED display.
71
72 :param image: The image to render.
73 :type image: PIL.Image.Image
74 """
75 assert(image.mode == self.mode)
76 assert(image.size == self.size)
77
78 image = self.preprocess(image)
79
80 if self.framebuffer.redraw_required(image):
81 left, top, right, bottom = self._apply_offsets(self.framebuffer.bounding_box)
82 width = right - left
83 height = bottom - top
84
85 self._set_position(top, right, bottom, left)
86
87 i = 0
88 buf = bytearray(width * height * 2)
89 for r, g, b in self.framebuffer.getdata():
90 if not(r == g == b == 0):
91 # 65K format 1
92 buf[i] = r & 0xF8 | g >> 5
93 buf[i + 1] = g << 3 & 0xE0 | b >> 3
94 i += 2
95
96 self.data(list(buf))
185def display(self, data):
186 cv2.imshow('frame', self.image.Convert(self.display_format, PySpin.HQ_LINEAR).GetNDArray())
187 # waitKey helps primitive UI cycle through events
188 cv2.waitKey(1)
69def display_image_file_on_face(self, image_name):
70 # load image and convert it for display on cozmo's face
71 image = Image.open(image_name)
72
73 # resize to fit on Cozmo's face screen
74 resized_image = image.resize(cozmo.oled_face.dimensions(), Image.NEAREST)
75
76 self.display_image_on_face(resized_image, True)
63def displayImageFileOnLCD(filename):
64 print 'displays ', filename
65 title = 'Review Mode'
66 # resize/dither to screen resolution and send to LCD
67 image = Image.open(filename)
68 im_width, im_height = image.size
69 if im_width < im_height:
70 image = image.rotate(90)
71 image.thumbnail(S_SIZE, Image.ANTIALIAS)
72 image_sized = Image.new('RGB', S_SIZE, (0, 0, 0))
73 image_sized.paste(image,((S_SIZE[0] - image.size[0]) / 2, (S_SIZE[1] - image.size[1]) / 2))
74 # draw filename
75 draw = ImageDraw.Draw(image_sized)
76 font = ImageFont.truetype('arial.ttf', 18)
77 draw.rectangle([(0, 0), (115, 22)], fill=(255,255,255), outline=(0,0,0))
78 draw.text((2, 2), title, fill='black', font=font)
79 draw.rectangle([(279, 217), (399, 239)], fill=(255,255,255), outline=(0,0,0))
80 draw.text((290, 218), filename, fill='black', font=font)
81 # display on LCD
82 image_sized = ImageOps.invert(image_sized)
83 image_sized = image_sized.convert('1') # convert image to black and white
84 lcd.write(image_sized.tobytes())

Related snippets