Hi I’ve bought the dispay pack2 and am trying to display an image. If I download the image and put it on the pi pico w then the image displays OK. I’m trying to get the image to be downloaded from a URL and displayed but am getting
MemoryError: memory allocation failed, allocating 21760 bytes
I’m new to this sort of coding and am struggling to see what I’m doing wrong. here is my full py code
import network
import urequests
import time
import picographics
import jpegdec
from pimoroni import Button
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect("SSID","password")
time.sleep(5)
print(wlan.isconnected())
display = picographics.PicoGraphics(display=picographics.DISPLAY_PICO_DISPLAY_2, rotate=0)
display.set_backlight(0.8)
# Create a new JPEG decoder for our PicoGraphics
j = jpegdec.JPEG(display)
# Open the JPEG file
#j.open_file("squid.jpg")
# Decode the JPEG
#j.decode(0, 0, jpegdec.JPEG_SCALE_FULL)
if wlan.isconnected():
res = urequests.get(url='https://squirrel365.io/tmp/squid.jpg')
# Open the JPEG file
#j.open_file("squid.jpg")
#imgBytes = getImageBytes()
j.open_RAM(memoryview(res.content))
# Decode the JPEG
j.decode(0, 0, jpegdec.JPEG_SCALE_FULL)
# Display the result
display.update()
Any ideas? Sorry if this is the wrong place to post this.
Kedge