Skip to content

Commit f90435a

Browse files
committed
fixes
1 parent 6c8c4f0 commit f90435a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

bmp_module.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def get_pixel_data_16bit(self, bmp_file):
196196
BMP_16BIT_RED_MASK,
197197
BMP_16BIT_GREEN_MASK,
198198
BMP_16BIT_BLUE_MASK,
199-
2
199+
2, 5
200200
)
201201
return bitmap
202202

@@ -206,12 +206,12 @@ def get_pixel_data_32bit(self, bmp_file):
206206
BMP_32BIT_RED_MASK,
207207
BMP_32BIT_GREEN_MASK,
208208
BMP_32BIT_BLUE_MASK,
209-
4
209+
4, 8
210210
)
211211
return bitmap
212212

213213
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):
215215
"""
216216
Ф-я считывает из файла двухмерный массив пикселей
217217
для 16/32 битных изображений без RLE-сжатия
@@ -225,9 +225,12 @@ def get_pixel_data_16_32bit(self, bmp_file, r_mask, g_mask, b_mask,
225225
bitmap.append(list())
226226
for j in range(width):
227227
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
230230
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)
231234
bitmap[i].append((red, green, blue))
232235
bytes_count = bytes_per_pixel * width
233236
if bytes_count % 4 != 0:

0 commit comments

Comments
 (0)