52
52
#pylint:disable=line-too-long,broad-except,redefined-outer-name
53
53
54
54
def _write_bmp_header (output_file , filesize ):
55
- # print('writing bmp header')
56
55
output_file .write (bytes ('BM' , 'ascii' ))
57
56
output_file .write (struct .pack ('<I' , filesize ))
58
57
output_file .write (b'\00 \x00 ' )
59
58
output_file .write (b'\00 \x00 ' )
60
59
output_file .write (struct .pack ('<I' , 54 ))
61
60
62
61
def _write_dib_header (output_file , bitmap ):
63
- # print('writing dib header')
64
62
output_file .write (struct .pack ('<I' , 40 ))
65
63
output_file .write (struct .pack ('<I' , bitmap .width ))
66
64
output_file .write (struct .pack ('<I' , bitmap .height ))
@@ -74,7 +72,6 @@ def _bytes_per_row(bitmap):
74
72
return pixel_bytes + padding_bytes
75
73
76
74
def _write_pixels (output_file , bitmap , palette ):
77
- # print('writing pixels')
78
75
row_buffer = bytearray (_bytes_per_row (bitmap ))
79
76
80
77
for y in range (bitmap .height , 0 , - 1 ):
@@ -94,7 +91,6 @@ def save_bitmap(bitmap, palette, file_or_filename):
94
91
:param bitmap: the displayio.Bitmap to save
95
92
:param palette: the displayio.Palette to use for looking up colors in the bitmap
96
93
"""
97
- print ("Saving bitmap" )
98
94
if not isinstance (bitmap , Bitmap ):
99
95
raise ValueError ('bitmap' )
100
96
if not isinstance (palette , Palette ):
@@ -106,15 +102,10 @@ def save_bitmap(bitmap, palette, file_or_filename):
106
102
output_file = file_or_filename
107
103
108
104
filesize = 54 + bitmap .height * _bytes_per_row (bitmap )
109
- # print('Bitmap height: ', bitmap.height)
110
- # print('Bitmap width: ', bitmap.width)
111
- # print('Filesize: ', filesize)
112
105
_write_bmp_header (output_file , filesize )
113
106
_write_dib_header (output_file , bitmap )
114
107
_write_pixels (output_file , bitmap , palette )
115
108
except Exception :
116
- print ('Error saving bitmap' )
117
109
raise
118
110
else :
119
111
output_file .close ()
120
- print ("Finished saving bitmap" )
0 commit comments