wongzlll
Posts: 5
Joined: Fri Mar 01, 2019 2:51 pm

pygame display picture

Thu Apr 04, 2019 6:26 am

Hi all,

When i tried this code to download the picture from website and display it on pygame, i got the following error (ImportError: DLL load failed: The specified module could not be found.)

Code: Select all

import pygame
from pygame.locals import *
import requests
from OpenSSL import SSL

pygame.init()

r1 = requests.get("https://cgaxisimages.ams3.digitaloceanspaces.com/home/klient.dhosting.pl/cgaxis/cgaxis.com/public_html/store/wp-content/uploads/2018/02/cgaxis_hdri_skies_01_57-1.jpg", verify=False)
r2 = requests.get("http://www.screenspro.com/thumbs/small4cc492db239c5.jpg")

with open('surface.png', 'wb') as f:
    f.write(r1.content)

with open('sea.png', 'wb') as f1:
    f1.write(r2.content)

screen = pygame.display.set_mode((600,440))
background_1 = pygame.image.load(f).convert()
background_2 = pygame.image.load(f1).convert()
bg_1 = background_1.get_rect()
bg_2 = background_2.get_rect()
bgrect = bg_1.move(300, 220)
bgrect2 = bg_2.move(300, 220)

while True:
    bgrect.blit(bgrect,(10,10))
    bgrect2.blit(bgrect, (10,10))
    pygame.display.update()

Please advise as due to the https:// i need to use SSL

scotty101
Posts: 3958
Joined: Fri Jun 08, 2012 6:03 pm

Re: pygame display picture

Thu Apr 04, 2019 8:34 am

Any reason why you can't just download the images and save them to your Pi rather than downloading them each time?

Can you post the exact error message so that we can see which line caused the error?
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

Return to “General discussion”