2015-09-06 12:54:58 +00:00
|
|
|
# ~*~ encoding: utf-8 ~*~ #
|
|
|
|
###########################
|
|
|
|
# TRAITEMENT D'IMAGES #
|
|
|
|
###########################
|
|
|
|
|
2015-09-06 14:01:17 +00:00
|
|
|
# classes
|
2015-09-06 14:28:56 +00:00
|
|
|
from classes import *
|
2015-09-06 14:01:17 +00:00
|
|
|
|
2015-09-06 12:54:58 +00:00
|
|
|
import sys
|
|
|
|
|
2015-09-08 19:17:00 +00:00
|
|
|
# lecture du fichier
|
|
|
|
with open( sys.argv[1] ) as file:
|
|
|
|
binFile = file.read()
|
|
|
|
|
|
|
|
# Instanciation du BMPFile
|
2015-09-06 21:34:26 +00:00
|
|
|
img = BMPFile()
|
2015-09-08 19:17:00 +00:00
|
|
|
|
|
|
|
# Parsing
|
|
|
|
img.parse( binFile );
|
2015-09-06 12:54:58 +00:00
|
|
|
|
2015-09-07 08:11:04 +00:00
|
|
|
|
2015-09-08 19:17:00 +00:00
|
|
|
# MODIFICATIONS des pixels
|
|
|
|
for line in img.content.map:
|
|
|
|
for pixel in line:
|
|
|
|
pixel.r = 255
|
|
|
|
pixel.g = 75
|
|
|
|
pixel.b = 255
|
2015-09-06 21:34:26 +00:00
|
|
|
|
|
|
|
|
2015-09-08 19:17:00 +00:00
|
|
|
# Unparsing
|
|
|
|
img.unparse()
|
2015-09-06 21:34:26 +00:00
|
|
|
|
2015-09-07 17:21:32 +00:00
|
|
|
|
2015-09-08 19:17:00 +00:00
|
|
|
print img.binData
|
2015-09-07 08:24:28 +00:00
|
|
|
|
2015-09-08 19:17:00 +00:00
|
|
|
# for line in img.content.map:
|
|
|
|
# for pixel in line:
|
|
|
|
# print "rgb(%s, %s, %s)" % (pixel.r, pixel.g, pixel.b)
|
|
|
|
# print
|