erreur de padding pour vérif de taille

This commit is contained in:
xdrm-brackets 2015-09-07 10:37:58 +02:00
parent 3904137b97
commit 9210ece885
3 changed files with 8 additions and 18 deletions

View File

@ -13,7 +13,7 @@ img.parse( sys.argv[1] );
### print header human-readable data ### ### print header human-readable data ###
print img.header.info() #print img.header.info()
### print file human-readable data ### ### print file human-readable data ###
#print img.readableData #print img.readableData
@ -26,17 +26,7 @@ print img.header.info()
for line in img.content.map:
#for line in img.content.map: for pixel in line:
# for pixel in line: print "rgb(%s, %s, %s)" % (pixel.r, pixel.g, pixel.b)
# print "rgb(%s, %s, %s)" % (pixel.r, pixel.g, pixel.b)
# print
for byte in img.content.bin:
print ord(byte),
print print
img.content.unparse( img.content.map )
for byte in img.content.bin:
print ord(byte),

View File

@ -79,7 +79,7 @@ class BMPHeader:
print "=====================" print "====================="
print "padding: %s" % ( (4- self.width*3 %4)%4 ) print "padding: %s" % ( (4- self.width*3 %4)%4 )
print "=====================" print "====================="
print
#################################################### ####################################################
@ -108,7 +108,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 = []
@ -189,7 +189,7 @@ class BMPFile:
with open( filename ) as file: with open( filename ) as file:
for byte in file.read(): for byte in file.read():
self.bin += byte; self.bin += byte;
self.readableData += str(hex(ord(byte))) + " " self.readableData += str(ord(byte)) + " "
headerSize = 54 headerSize = 54

Binary file not shown.