Traitement de fichier bpp1,4,8,24 fonctionnel, rapidité et efficience de l'algo à revoir
This commit is contained in:
parent
ffcfbf1f69
commit
3494ecec32
|
@ -269,7 +269,7 @@ class RGBPixel:
|
|||
|
||||
# gestion des différents bpp
|
||||
if bpp == 1:
|
||||
self.intData = [ int( (r+g+b)/3 > 256/2 ) ]
|
||||
self.intData = [ int( (r+g+b)/3 >= 128 ) ]
|
||||
self.binData = chr( self.intData[0] )
|
||||
elif bpp == 4:
|
||||
self.intData = [ int( 16 * ((r+g+b)/3) / 256 ) ]
|
||||
|
@ -287,6 +287,7 @@ class RGBPixel:
|
|||
|
||||
def setBin(self, binData, index, bpp=24):
|
||||
if bpp not in [1,4,8,24]:
|
||||
if not hasattr(self, 'bpp'): # si l'attribut n'est pas déjà défini, alors on met la valeur par défaut
|
||||
self.bpp = 24
|
||||
else:
|
||||
self.bpp = bpp
|
||||
|
|
|
@ -201,10 +201,6 @@ class PixelColor(r, g, b, bpp=24):
|
|||
#######################################################################
|
||||
ALGO:
|
||||
|
||||
binData="01234567890123456789012345678\0ABCD"
|
||||
|
||||
i = 29.125 + .125
|
||||
bpp = 1
|
||||
|
||||
firstBit = int(i) + i%1.0; # retourne le rang du premier bit (pas byte)
|
||||
lastBit = firstBit + bpp/8.0
|
||||
|
|
21
code/bmp.py
21
code/bmp.py
|
@ -29,24 +29,21 @@ def testFileIntegrity():
|
|||
# Parsing
|
||||
img.parse( binFile );
|
||||
|
||||
# MODIFICATIONS des pixels
|
||||
for line in img.content.map:
|
||||
for pixel in line:
|
||||
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
|
||||
pixel.setRGB(
|
||||
( 255 - pixel.r ) % 256,
|
||||
( 255 - pixel.g ) % 256,
|
||||
( 255 - pixel.b ) % 256
|
||||
)
|
||||
|
||||
|
||||
# # Unparsing
|
||||
# img.unparse()
|
||||
# Unparsing
|
||||
img.unparse()
|
||||
|
||||
|
||||
# print img.binData
|
||||
print img.binData
|
||||
|
||||
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 768 KiB |
Binary file not shown.
After Width: | Height: | Size: 768 KiB |
Binary file not shown.
After Width: | Height: | Size: 768 KiB |
Loading…
Reference in New Issue