IPB

Bienvenue invité ( Connexion | Inscription )

2 Pages < 1 2 
Reply to this topicStart new topicStart Poll

En ligne · [ Standard ] · Linéaire+

> Pfouuu, java me fait chier, là ...

Gfx
post 14/08/2002 21:43
Message #31


Goule
****

Groupe : Membres
Messages : 980
Inscrit le : 01/08/2002 23:00
Lieu : Lyon
Membre no. 106



Installe l'extension PIL. Ca rulez pour traiter les images.


--------------------
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
momo
post 14/08/2002 21:46
Message #32


lvl1 male rogue St=1 Dex=5 Int=17 Wi=5 Ch=0
****

Groupe : Modérateurs
Messages : 1,730
Inscrit le : 16/05/2002 23:00
Lieu : .gif
Membre no. 12



ce serait trop facile du coup ...


--------------------
Natural evolution insists that we are apes; artificial evolution insists that we are machines with an attitude.
Kevin Kelly - Out of control
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Poischack
post 14/08/2002 21:51
Message #33


Goule
****

Groupe : Modérateurs
Messages : 515
Inscrit le : 19/07/2002 23:00
Lieu : Alsace.gif
Membre no. 94



smile.gif pff pourquoi faire facil quan don peut faire compliqué ? smile.gif


--------------------
"L'éternité c'est long, surtout vers la fin", Kafka ...
Grâce à l'ordinateur, on peut faire plus rapidement des choses qu'on n'aurait pas eu besoin de faire sans ordinateur.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
momo
post 15/08/2002 10:53
Message #34


lvl1 male rogue St=1 Dex=5 Int=17 Wi=5 Ch=0
****

Groupe : Modérateurs
Messages : 1,730
Inscrit le : 16/05/2002 23:00
Lieu : .gif
Membre no. 12



et pourquoi ne pas develloper sa propre librairie graphique en python .. smile.gif


--------------------
Natural evolution insists that we are apes; artificial evolution insists that we are machines with an attitude.
Kevin Kelly - Out of control
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
momo
post 16/08/2002 10:24
Message #35


lvl1 male rogue St=1 Dex=5 Int=17 Wi=5 Ch=0
****

Groupe : Modérateurs
Messages : 1,730
Inscrit le : 16/05/2002 23:00
Lieu : .gif
Membre no. 12



CODE

from Tkinter import *
def Dwords(files):
temp1=ord(files.read(1))*256**0
temp2=ord(files.read(1))*256**1
temp3=ord(files.read(1))*256**2
temp4=ord(files.read(1))*256**3
return temp1+temp2+temp3+temp4

def Words(files):
temp3=ord(files.read(1))*256**0
temp4=ord(files.read(1))*256**1
return temp3+temp4


def Read_Header_Bmp(bmpfile):
text=bmpfile.read(2)
print
print bmpfile
print "========BMP-Header Information========"
if text=="BM":
print "first Dword 'BM' : ok"
else:
print text
bfSize=Dwords(bmpfile)
print "File size in Dwords:", bfSize
reserv1=Words(bmpfile)
print "Must be zero:",
if reserv1==0:
print "ok"
else:
print "error"
reserv2=Words(bmpfile)
print "Must be zero:",
if reserv2==0:
print "ok"
else:
print "error"

offbits=Dwords(bmpfile)
print "Image data offset:",offbits


info=Words(bmpfile)
print "Info header=",info,"bytes"
#Why Dwords are differents here ???
# it seems to be a .read error ... ???
temp1=ord(bmpfile.read(1))*256**2
temp2=ord(bmpfile.read(1))*256**3
temp3=ord(bmpfile.read(1))*256**0
temp4=ord(bmpfile.read(1))*256**1
width=temp1+temp2+temp3+temp4
print "Width=",width
temp1=ord(bmpfile.read(1))*256**2
temp2=ord(bmpfile.read(1))*256**3
temp3=ord(bmpfile.read(1))*256**0
temp4=ord(bmpfile.read(1))*256**1
height=temp1+temp2+temp3+temp4
print "Height=",height
temp1=ord(bmpfile.read(1))*256**2
temp2=ord(bmpfile.read(1))*256**3
temp3=ord(bmpfile.read(1))*256**0
temp4=ord(bmpfile.read(1))*256**1
planes=temp1+temp2+temp3+temp4
print "Must be '1':",
if planes==1:
print "ok"
else:
print "error"
bitcount=Words(bmpfile)
print "Bits per pixel:",bitcount
compression=Dwords(bmpfile)
print "Compression type:",compression
sizeimage=Dwords(bmpfile)
print "Image size in Bytes:",sizeimage
xpxelpermeter=Dwords(bmpfile)
print "Pixels per meter (X):",xpxelpermeter
ypxelpermeter=Dwords(bmpfile)
print "Pixels per meter (Y):",ypxelpermeter
colorused=Dwords(bmpfile)
if colorused==0:
print "All colors used"
else:
print colorused,"colors used"
colorimportant=Dwords(bmpfile)
print colorimportant,"important color(s)"
print "============End of header ============"
return [width,height,bitcount,offbits,sizeimage]

def Bmp_read_24(offbits,width,height,bmpfile,size):
data=[]
print bmpfile.tell()
bmpfile.seek(0)
bmpfile.seek(offbits)
if bmpfile.tell()<>offbits:
print "file error"
for count in range(0,size,3):
blue=ord(bmpfile.read(1))
green=ord(bmpfile.read(1))
red=ord(bmpfile.read(1))
data.append([red,green,blue])
return data


# file=open("C:/Documents and Settings/momo1/Bureau/Python/Test.dat","rb")
file=open("Test.dat","rb")
bmpinfo=Read_Header_Bmp(file)
if bmpinfo[2]==24:
print "launch 24 bits decoding routine"
bmpdata=Bmp_read_24(bmpinfo[3],bmpinfo[0],bmpinfo[1],file,bmpinfo[4])
file.close()
print"file closed"
root=Tk()
bitmap=Canvas(width=bmpinfo[0],height=bmpinfo[1])
bitmap.pack()
root.title("just a dumb test")
counter=0
# need to find a less memory and cpu hungry method
# a "raw" bitmap would be perfect
for count1 in range(bmpinfo[1],0,-1):
for count in range(bmpinfo[0]+1):
color="#%02x%02x%02x" % (bmpdata[counter][0],bmpdata[counter][1],bmpdata[counter][2])
counter+=1
bitmap.create_line(count,count1,count,count1+1,fill=color)
root.mainloop()

bon à part le fait que la mauvaise idée d'utiliser un canvas pour l'affichage en fait un gouffre cpu et ram, ça marche ... pour les bmp 24 bits ... du moins
( même s'il va falloir que je comprennes d'où vient mon pb avec le decodage Width et Height ... :/ )


--------------------
Natural evolution insists that we are apes; artificial evolution insists that we are machines with an attitude.
Kevin Kelly - Out of control
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

2 Pages < 1 2
Reply to this topicTopic OptionsStart new topic
1 utilisateur(s) sur ce sujet (1 invité(s) et 0 utilisateur(s) anonyme(s))
0 membre(s) :
 

Version bas débit Nous sommes le : : 20/06/2024 2:24