Skip to content
Snippets Groups Projects
Commit a77c2069 authored by Fatima Almohamed Alsadou's avatar Fatima Almohamed Alsadou
Browse files

fonction affiche_image

parent ec836b65
No related branches found
No related tags found
No related merge requests found
...@@ -2,29 +2,27 @@ imagef=Image.open('images/images/galets.png') ...@@ -2,29 +2,27 @@ imagef=Image.open('images/images/galets.png')
def affiche_image(fichier:str,image:str): def affiche_image(fichier:str,image:str):
""" """
affiche l'image dont les coordonnées sont sont contenus dans le fichier fichier affiche l'image dont les coordonnées sont contenus dans le fichier fichier
Précondition : Précondition :
Exemple(s) : Exemple(s) :
$$$ $$$
""" """
coord=[] coord=[]
res="" res=""
imageaconvertir=Image.open(image) imageaconvertir=Image.open('calbuth2.png')
im=imageaconvertir.convert('RGB') im=imageaconvertir.convert('RGB')
dessin=ImageDraw.Draw(im) dessin=ImageDraw.Draw(im)
with open(fichier,'r') as f: with open(fichier,'r') as f:
for line in f: for line in f:
l coord=coord_str(line)
for i in range(1,len(line)-2): if len(coord)==7:
if line[i]!=','and line[i]!="'" : dessin.rectangle(((coord[0],coord[1]),(coord[2],coord[3])),fill=(coord[4],coord[5], coord[6]))
res+=(line[i])
else: elif len(coord)==4:
res.strip() dessin.rectangle(((coord[0],coord[1]),(coord[2],coord[3])),fill=None)
coord.append(int(res))
im.show()
for i in range(0,len(coord),6):
dessin.rectangle(((coord[i],coord[i+1]),(coord[i+2],coord[i+3])),fill=(coord[i+4],coord[i+5],coord[i+6]))
im.show()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment