Vous pouvez tester le script dans l’émulateur en tapant >> dess()
Version améliorée du script gimpnumworks.py dans le sens où l’on compresse les données de l’image.
Par exemple im="A7B3CD3"
signifie 7 fois le caractère “A”, 3 fois le “B”, 1 fois le “C” et 3 fois le “D” ce qui est plus court en mémoire que im="AAAAAAABBBCDDD"
def nw():
lett="ABCDEFGHIJKLMNOP"
img=gimp.image_list()[0]
pdb.gimp_image_scale(img, 80, 55)
drw = pdb.gimp_image_active_drawable(img)
if not(pdb.gimp_drawable_is_indexed(drw)):
pdb.gimp_convert_indexed(img, 0, 0, 16, 0, 1, 0)
im=""
pal=[]
c=0
for i in range(4400):
v=list(pdb.gimp_image_pick_color(img,drw,i%80,i//80,1,0,0))[:-1]
if v not in pal: pal.append(v)
cour = pal.index(v)
if i==0 : prec = cour
if prec != cour and i>0:
im+=lett[prec]
if c>1: im+=str(c)
c=1
prec = cour
else:
c+=1
print "pal="+str(pal)
print "im=\""+im+"\""
from kandinsky import * pal=[[145, 27, 20], [47, 15, 14], [6, 4, 1], [31, 10, 10], [77, 20, 18], [107, 17, 16], [138, 47, 47], [192, 126, 132], [155, 146, 140], [169, 136, 77], [216, 181, 132], [239, 215, 191], [58, 41, 39], [116, 87, 44], [212, 219, 229], [84, 77, 83]] im="ABC7D3BEB2DCDCDBC4BF2BDCD2C8GHIJ2K6L2ME9BN4J2KL3KG2EA2EC7D3BEB2DCDCDBC4BE2D2CD2C7GHIJ2K6L2NE10N3J2K2L3KGAGA3EC7D3BE2BDCDCDBC4BE2DC10GHIJ2K2L6NE3F4E2N3J3K2L3KFAGFA3EC8D2BE2BDCDCDBC4BEBDC9HGIJ2KL7NE2F6EJNJ3K3L3KGFGEFA3EC8D3E2BDCDCDBC4DBDC8DH2IJ2KL7KEBEF5GNJ4K2L4JF2GMNFA3EC8D3E2BDCDCD2C4DBDC7DH2INJ2KL7KJ10KJK3L4JEFGN3FA3EC10DE2BDCDC2DC4D2C7BHGIN2JK2L8K14L4NEFGJN3FA2F2C10DBEBDC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13B" def dess(): r = 0 i=0 while r<len(im): s = im[r] n="" r+=1 while r<len(im) and "9">=im[r] >="0": n+=im[r] r+=1 nb = 1 if n=="" else int(n) c = pal[ord(s)-65] for j in range(nb): fill_rect(4*(i%80),4*(i//80),4,4,(c[0],c[1],c[2])) i+=1