Skip to content

Commit b8758f9

Browse files
authored
Merge pull request #22 from matt-land/fix-variable-reference
fix for #21, always create reference
2 parents 5b89512 + f9cb0cd commit b8758f9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

adafruit_bitmapsaver.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# SPDX-FileCopyrightText: 2019 Dave Astels for Adafruit Industries
2+
# SPDX-FileCopyrightText: 2022 Matt Land
23
#
34
# SPDX-License-Identifier: MIT
45

@@ -10,7 +11,7 @@
1011
Make a screenshot (the contents of a displayio.Display) and save in a BMP file.
1112
1213
13-
* Author(s): Dave Astels
14+
* Author(s): Dave Astels, Matt Land
1415
1516
Implementation Notes
1617
--------------------
@@ -79,6 +80,7 @@ def _write_pixels(output_file, pixel_source, palette):
7980
saving_bitmap = isinstance(pixel_source, Bitmap)
8081
width, height = _rotated_height_and_width(pixel_source)
8182
row_buffer = bytearray(_bytes_per_row(width))
83+
result_buffer = False
8284
for y in range(height, 0, -1):
8385
buffer_index = 0
8486
if saving_bitmap:
@@ -98,8 +100,9 @@ def _write_pixels(output_file, pixel_source, palette):
98100
row_buffer[buffer_index] = b & 0xFF
99101
buffer_index += 1
100102
output_file.write(row_buffer)
101-
for i in range(width * 2):
102-
result_buffer[i] = 0
103+
if result_buffer:
104+
for i in range(width * 2):
105+
result_buffer[i] = 0
103106
gc.collect()
104107

105108

0 commit comments

Comments
 (0)