@@ -196,7 +196,7 @@ def get_pixel_data_16bit(self, bmp_file):
196
196
BMP_16BIT_RED_MASK ,
197
197
BMP_16BIT_GREEN_MASK ,
198
198
BMP_16BIT_BLUE_MASK ,
199
- 2
199
+ 2 , 5
200
200
)
201
201
return bitmap
202
202
@@ -206,12 +206,12 @@ def get_pixel_data_32bit(self, bmp_file):
206
206
BMP_32BIT_RED_MASK ,
207
207
BMP_32BIT_GREEN_MASK ,
208
208
BMP_32BIT_BLUE_MASK ,
209
- 4
209
+ 4 , 8
210
210
)
211
211
return bitmap
212
212
213
213
def get_pixel_data_16_32bit (self , bmp_file , r_mask , g_mask , b_mask ,
214
- bytes_per_pixel ):
214
+ bytes_per_pixel , bits_per_color ):
215
215
"""
216
216
Ф-я считывает из файла двухмерный массив пикселей
217
217
для 16/32 битных изображений без RLE-сжатия
@@ -225,9 +225,12 @@ def get_pixel_data_16_32bit(self, bmp_file, r_mask, g_mask, b_mask,
225
225
bitmap .append (list ())
226
226
for j in range (width ):
227
227
rgb = read_int_from_file (bmp_file , bytes_per_pixel )
228
- red = (rgb & r_mask ) >> 16
229
- green = (rgb & g_mask ) >> 8
228
+ red = (rgb & r_mask ) >> 2 * bits_per_color
229
+ green = (rgb & g_mask ) >> bits_per_color
230
230
blue = rgb & b_mask
231
+ red = convert (red , bits_per_color , 8 )
232
+ green = convert (green , bits_per_color , 8 )
233
+ blue = convert (blue , bits_per_color , 8 )
231
234
bitmap [i ].append ((red , green , blue ))
232
235
bytes_count = bytes_per_pixel * width
233
236
if bytes_count % 4 != 0 :
0 commit comments