Bonjour,
j'ai un petit probl=E8me en Jython avec swing.ImageIcon()
voil=E0 je voudrais pouvoir charger mon image depuis un file-like object
(StringIO) mais je ne sais pas comment le passer =E0 ImageIcon()?
il est possible (d'apr=E8s la doc) de passer "an array of bytes which
were read from an image file containing a supported image format, such
as GIF or JPEG."
mon fichier est au format jpeg mais comment le transformer en array of
bytes???
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
kaerbuhez
Bonjour, j'ai un petit problème en Jython avec swing.ImageIcon()
voilà je voudrais pouvoir charger mon image depuis un file-like object (StringIO) mais je ne sais pas comment le passer à ImageIcon()?
il est possible (d'après la doc) de passer "an array of bytes which were read from an image file containing a supported image format, such as GIF or JPEG."
mon fichier est au format jpeg mais comment le transformer en array of bytes???
Seb
# donner le path de l'icone en premier argument import sys from javax import swing bytes_string=open(sys.argv[1]).read() bytes_array=[ord(x) for x in bytes_string] i=swing.ImageIcon(bytes_array) print i.iconHeight!=-1 and 'Réussi !' or 'Raté !'
Script testé sous jython2.1/java1.5/WinXP.
Bonjour,
j'ai un petit problème en Jython avec swing.ImageIcon()
voilà je voudrais pouvoir charger mon image depuis un file-like object
(StringIO) mais je ne sais pas comment le passer à ImageIcon()?
il est possible (d'après la doc) de passer "an array of bytes which
were read from an image file containing a supported image format, such
as GIF or JPEG."
mon fichier est au format jpeg mais comment le transformer en array of
bytes???
Seb
# donner le path de l'icone en premier argument
import sys
from javax import swing
bytes_string=open(sys.argv[1]).read()
bytes_array=[ord(x) for x in bytes_string]
i=swing.ImageIcon(bytes_array)
print i.iconHeight!=-1 and 'Réussi !' or 'Raté !'
Bonjour, j'ai un petit problème en Jython avec swing.ImageIcon()
voilà je voudrais pouvoir charger mon image depuis un file-like object (StringIO) mais je ne sais pas comment le passer à ImageIcon()?
il est possible (d'après la doc) de passer "an array of bytes which were read from an image file containing a supported image format, such as GIF or JPEG."
mon fichier est au format jpeg mais comment le transformer en array of bytes???
Seb
# donner le path de l'icone en premier argument import sys from javax import swing bytes_string=open(sys.argv[1]).read() bytes_array=[ord(x) for x in bytes_string] i=swing.ImageIcon(bytes_array) print i.iconHeight!=-1 and 'Réussi !' or 'Raté !'
Script testé sous jython2.1/java1.5/WinXP.
Sébastien Ramage
ooh ça fonctionne à merveille yavait rien de bien compliqué en fait, et j'apprends une nouvelle syntaxe au passage, c'est court et efficace
merci beaucoup :)
ooh ça fonctionne à merveille
yavait rien de bien compliqué en fait, et j'apprends une nouvelle
syntaxe au passage, c'est court et efficace