gimpnumworks.py

Created by schraf

Created on July 23, 2023

5.17 KB

Affiche une photo sur la calculatrice

But : Afficher une image quelconque (80*60 pixels avec 16 couleurs) sur la calculatrice

Attention : Depuis la dernière mise à jour proposée par Numwroks cette version peut poser des problèmes de mémoire, utilisez plutôt la version 2

Explications en vidéo

  • Lancez l’éditeur d’image gratuit Gimp et ouvrir une image quelconque
  • Utilisez l’outil de sélection rectangulaire et dans les options de cet outil choisir “Fixé proportions 320:240” pour sélectionner avec une forme semblable à celle de la calculatrice (vous pouvez aussi choisir le format 4:3). Comme me l’a fait remarquer un internaute, le format de l’écran est bien 4:3 mais le bandeau orange fait que dans la réalité on ne peut dessiner que sur une zone de 320x222 pixels. Si bien que dans vous pouvez choisir 320:220 ou 320:224 comme proportions dans Gimp et dans le programme principal vous remplacez le 60 par 55 (4x55=220) ou 56 (4x56=224).
  • Sélectionnez la zone à conserver puis Image - Rogner selon la sélection
  • Ouvrir la console Python de Gimp par Filtres - Python-Fu - Console
  • Copiez le code ci-dessous et le coller dans la console
def nw():
    lett="0123456789ABCDEF"
    img=gimp.image_list()[0]
    pdb.gimp_image_scale(img, 80, 60)
    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=[]
    for i in range(4800):
      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)
      im+=lett[pal.index(v)]
    print "pal="+str(pal)
    print "im=\""+im+"\""


  • Faire Entrée - Entrée pour obtenir >> à l’affichage et pas ...
  • Tapez


from kandinsky import *

pal=[[10, 9, 19], [145, 134, 125], [235, 213, 204], [227, 195, 168], [194, 162, 136], [127, 98, 80], [84, 87, 92], [27, 70, 102], [23, 50, 70], [25, 29, 35], [62, 46, 38], [178, 166, 158], [160, 129, 105], [91, 68, 55], [196, 98, 81], [170, 80, 66]]
im="000001222222222222222222222222333334456777777899888888877888888777778888887889990000AB22222222222222222222222223333334C6677777899888888878878909777788888888788800006B222222222222222222222222222333334C16887778990999898888789987777887778777780000D22233222222222222222223222333333344C5D97888890090999988879098887777778777770000D42333333222222222222223322333333344411D8898889900009998988099988887777777770000AC34444B32222222333333333333333333344415DA88878990009998899998998898877877770000A5C4B34432222222333344444443333333344411DDA88888900000998898989098999878777700009A5B22BBB3222222344444444434333333334B155DAA8888889999988888998909789878877800009AD5C5111B22222344444B4444433333333344C55DDAA888788809988789900999889888877800000A5B21AA6422222B444444CCC4433333333344C5DDDAAA99978999988988890099998888887800000AB22110A52222244C444CC422234444333444C5DDDAAAA9987888888898999098989878788800000A222AA0A53222344CC4CC323333B4CC44444CC5DDDDAAAA987888888988987909098888877800000DB221AA65322234CCCCC4BB3BB155555C444C5DDDDDDAAAA988888889989978009988877777000001322B111C22224CCCC444422221AAAD555CCC5DDDDDDDAAAA887888889089878009888877770000AB3333333222224CCCC44C32222BA0AADDD5C55DDDDDDDDAAAA87888888909988998888887880000632444344322234CCCC434322226A0ADADDD5555DDDDDDDAAAA98877889999988899888898880000522333343222234CCCC43332222DAADDAADD555DDDDDDDDDAAAA9877799909998988898888880000122223332222234CCCC433332221D66ADDD55555555DDDDDDAAAA987789999989888899988880000122222322222244CCCC333333333B111DD55CCC55555DDDDDDAAAA98888999988888899888880009122222222222344CCC43333333344CC5D55C4444CCC5DDDDDADDAAA8888888999888888889980009B22222222222344CCC4333333334CC5555C4333444C5DDDDDDDADAAA988998999988888988980009B22222222222344CCCC43333333344CCC44333444CC5DDDDDDDDDAAAA8889889098888798889000AB222222222234CCCCCC3333333333444433333444CC55DDDDDDDDDAAAA8788888999988988890009B222222222244CCCCCC4333333333333333333344CC5DDDDDDDDDADAAAA878877999999999880009B222222222344CCCCCC433333232222233333344CC55DDDDDDDDDDDAAAAA87877789999099980009B222222222344CCCCCC433333222232233333444CC55DDDDDDDDDDAAAAAA98877778999909090009122222222344CC555CC433333333222233333444C55DDDDDDDDDDDAAAAAAAA987777899999090000122222222344C55555C43333333323333333444CC55DDDDDDDDDDDDAAAAAAAA988878999900900005222222234CCC55555C43333333333333334444CC5DDDDDDDDDDDDDDAAAAAAA098777899900000005222222234CC55555554333333333333333344CC5DDDDDDDDDDDDDDDAAAAAAAAA988889000000000A32222234CCC5555555C33333333333333444CCC5DDDDDDDDDDDDDDDDAAAA0AAAA9889000000000094222224C555555555D543333333333333444CC55DDDDDDDDDDDDDDDDAAAAAAAAAA99900000000000B22223C5555555555D5C333333333333444CCC55DDDDDDDDDDDDDDDAAAAAADDAAA9900000000000012222245DDDDD55DDDDC33333333333444CCC55DDDDDDDDDDDDDDDDAAAADDDDAAA90000000000000522222245AAADDDD5DD54333333333344CCCC55DDDDDDDDDDDDDDDDAAADDDDAAAA000000000000006322222225DDDDDDDDDC33333333334444CCC55DDDDDDDDDDDDDDDDDDDDDDDAAA900000000000000AB22222223C55555CCC443333333344444CC555DDDDDDDDDDDDDDDDDDDADDDAA900000000000000001222222224CCCCC44443333333334444CCC55DDDDDDDDDDDDDDDDAADDDDDAA9000000000000000001222222223CCC4444443333333344444CCC555DDDDDDDDDDDDDDAAADDDDAA0000000000000000000A322232224CC4444444333333334444CCCC555DDDDDDDDDDDDDDAAAAAAAA000000000000000000000B22443334CCC444444433333434444CCC55555DDD5DDDDDDDDDAAAAAAA00000000000000000000001224EC4CCC4CCC44444433444444CCCCC5555555555DDDDDDDDAAAAAAA00000000000000000000009224FFFFF5CCCCCC444443444444CCC55555555555555DDDDDDAAAAAAA00000000000000000000000B224FFFFFFFF5CCCCCC44444444CCC555555555555555DDDDDAAAAAAAA00000000000000000000006224EFFFCCCFFFFF5CCC444444CCCC5555555555555555DDDDDAAADAAA90000000000000000000009B24EEFFFECC5FFFFFEC44444CCCCC55555555555555555DDDDDDDDDAA9900000000000000000000012344EEEEEEFFFFFFC444444CCCC555555555555555555DDDDDD616AAA9000000000000000000000AB3432234EEEFFFF44434444CCCCCC5555555555555555DDDDDDBB6D6A9000000000000000000000912443323EEEFFFCC4444444CCC55C5555555555555555DDDDD52216AA90000000000000000000000D224444CFFFFFFCC4444444CCC5C555555555CC555555DDADD522B6AA90000000000000000000000A32244CFFFFFF5CCC444444CCCCC5555555CCCC55555DDADDD5BB16AA999000000000000000000009C2222B4C55555CCC44444CCCCC5CCC555CCCCCCC55DDADDDDDDD6AAAA89000000000000000000000522222234CCCCCCCC444CC1CCCCCCC5CCCCCCCCC5DDDDDDDDDDD6666669000000000000000000000D32222233BBCCCCCC444CC11CCCCCCCCCCCCCC55DADDDDDDDDD6B1116A00009996666000000000009422223333444CCCCCCCCC11CCCCCCCCCCCCC55DDDDDDDDDDDD61116AA09666611111000000000000532223333444CCCCCCCCCC1CCCCCCCCCCC55DDDDDDDDDDDDDDDDDAAA661BB11B1B11000000000000A43333333444CCCCCCCCCCCCCCCCCCCC55555DDDDDDDDDDDDDDAAD661BBBBBBBBBBB0000000000000A43333334B11CCCCCCCCCC5CCCCCC55555555DDDDDDDDDDDDD61BBBBBBBBBBBBBBB00000000000000A1B33334411CC5CCCCCC55C555555555555555555DDDDD61BB2222222222BBBBBB0000000000000000A1B34BB111C555555555DDDDD55555555555555DD51B22222222222222BBBBB1"

def rect(x,y,c):
  for i in range(16):
    set_pixel(4*x+i%4,4*y+i//4,c)

def dess():
  for i in range(80*60):
    c = pal[int("0x"+im[i])]
    rect(i%80,i//80,color(c[0],c[1],c[2]))

dess()

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.