This commit is contained in:
xdrm-brackets 2015-09-09 15:52:20 +02:00
parent d223aa1902
commit 4b34b3625e
5 changed files with 27 additions and 14 deletions

View File

@ -1,7 +1,5 @@
# ~*~ encoding: utf-8 ~*~ #
import sys
#################################################
# classe qui parse le header (binaire) en objet #
#################################################
@ -35,6 +33,7 @@ class BMPHeader:
# parse le header au format bin en objet
def parse(self, binHeader=""):
# on utilise l'argument si on l'a sinon l'attribut
if binHeader != "":
parsingData = binHeader
@ -67,6 +66,7 @@ class BMPHeader:
self.intData = []
for byte in parsingData:
self.intData.append( ord(byte) )
# fonction qui créer <self.binData> à partir des attributs

View File

@ -143,4 +143,6 @@ Classes:
#############
## To Do ##
#############
[x] faire que le unparse du content créée le header
[x] gestion de la palette (attribut au <parse>) définit par défaut au <unparse>
[x] faire que le unparse du content créée le header
[ ] prise en charge des formats 1, 4, et 8 bpp

5
code/Noise.py Normal file
View File

@ -0,0 +1,5 @@
# ~*~ encoding: utf-8 ~*~ #
class Noise:
def

View File

@ -4,7 +4,7 @@
###########################
# classes
from classes import *
from BMPFile import *
import random
import sys
@ -20,19 +20,24 @@ def testFileIntegrity():
# Parsing
img.parse( binFile );
# MODIFICATIONS des pixels
for line in img.content.map:
for pixel in line:
pixel.r = 255
pixel.g = 75
pixel.b = 255
print "rgb(%s, %s, %s)" % (pixel.r, pixel.g, pixel.b)
print
# # MODIFICATIONS des pixels
# for line in img.content.map:
# for pixel in line:
# pixel.r = 255
# pixel.g = 75
# pixel.b = 255
# Unparsing
img.unparse()
# # Unparsing
# img.unparse()
print img.binData
# print img.binData
@ -42,8 +47,8 @@ def testManualCreation():
img = BMPFile()
for y in range(0, 100):
img.content.map.append( [] )
for x in range(0, 100):
img.content.map[y].append( RGBPixel(
for x in range(0, 1000):
img.content.map[y].append( PixelColor(
random.randint(0, 255),
random.randint(0, 255),
random.randint(0, 255)
@ -54,4 +59,5 @@ def testManualCreation():
print img.binData
# MAIN
testManualCreation()
#testManualCreation()
testFileIntegrity()

BIN
code/images/lena.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 KiB