bmp.readme fini, reste à appliquer
This commit is contained in:
parent
be81c0ae80
commit
aeb487041d
BIN
code/blue.bmp
BIN
code/blue.bmp
Binary file not shown.
Before Width: | Height: | Size: 126 B |
|
@ -1,6 +1,5 @@
|
||||||
# ~*~ encoding: utf-8 ~*~ #
|
# ~*~ encoding: utf-8 ~*~ #
|
||||||
|
|
||||||
import binascii
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
#################################################
|
#################################################
|
||||||
|
@ -66,6 +65,11 @@ class BMPHeader:
|
||||||
|
|
||||||
# fonction qui créer <self.bin> à partir des attributs
|
# fonction qui créer <self.bin> à partir des attributs
|
||||||
def unparse(self):
|
def unparse(self):
|
||||||
|
|
||||||
|
# pas de gestion du header complémentaire
|
||||||
|
self.infoSize = 54
|
||||||
|
self.offset = 54
|
||||||
|
|
||||||
bytes = []
|
bytes = []
|
||||||
bytes += [ self.fromInt(self.signature, 2) ] # signature
|
bytes += [ self.fromInt(self.signature, 2) ] # signature
|
||||||
bytes += [ self.fromInt(self.fileSize, 4) ] # taille fichier BMP
|
bytes += [ self.fromInt(self.fileSize, 4) ] # taille fichier BMP
|
||||||
|
@ -127,8 +131,8 @@ class BMPHeader:
|
||||||
return intReturn
|
return intReturn
|
||||||
|
|
||||||
# écrit le valeur entière <intCode> en octet bourrés jusqu'à la taille <N>
|
# écrit le valeur entière <intCode> en octet bourrés jusqu'à la taille <N>
|
||||||
def fromInt(self, intCode, N):
|
def fromInt(self, value, size):
|
||||||
s = '0' + bin(intCode)[2:]
|
s = '0' + bin(value)[2:]
|
||||||
rtn = ""
|
rtn = ""
|
||||||
while s != "":
|
while s != "":
|
||||||
rtn += chr( int(s[-8:], 2) )
|
rtn += chr( int(s[-8:], 2) )
|
||||||
|
@ -136,7 +140,7 @@ class BMPHeader:
|
||||||
|
|
||||||
# on rajoute des zéros si besoin de padding
|
# on rajoute des zéros si besoin de padding
|
||||||
if N > len(rtn):
|
if N > len(rtn):
|
||||||
rtn = chr(int( "0" * ( N-len(rtn) ) )) + rtn
|
rtn = chr(int( "0" * (size - len(rtn)) )) + rtn
|
||||||
|
|
||||||
return rtn
|
return rtn
|
||||||
|
|
||||||
|
@ -167,7 +171,7 @@ class BMPContent:
|
||||||
# si le fichier a une mauvaise taille donc mauvais format
|
# si le fichier a une mauvaise taille donc mauvais format
|
||||||
if not len(binContent) == correctSize:
|
if not len(binContent) == correctSize:
|
||||||
print "Mauvais format (erreur de taille)"
|
print "Mauvais format (erreur de taille)"
|
||||||
# exit()
|
exit()
|
||||||
|
|
||||||
# attribution de la map
|
# attribution de la map
|
||||||
self.map = []
|
self.map = []
|
||||||
|
|
BIN
code/classes.pyc
BIN
code/classes.pyc
Binary file not shown.
BIN
code/green.bmp
BIN
code/green.bmp
Binary file not shown.
Before Width: | Height: | Size: 126 B |
BIN
code/red.bmp
BIN
code/red.bmp
Binary file not shown.
Before Width: | Height: | Size: 126 B |
BIN
code/rgbw.bmp
BIN
code/rgbw.bmp
Binary file not shown.
Before Width: | Height: | Size: 138 B |
BIN
code/test.bmp
BIN
code/test.bmp
Binary file not shown.
Before Width: | Height: | Size: 170 B |
Loading…
Reference in New Issue