From 62c8aa4d3d82cd4232320e4da30dfd38fd0d1d07 Mon Sep 17 00:00:00 2001 From: kmatch98 <33587466+kmatch98@users.noreply.github.com> Date: Sun, 28 Feb 2021 17:34:57 -0600 Subject: [PATCH 1/3] Reinitialize the result_buffer When using the displayio's `fill_area` function, it does not copy anything for pixels where no Group, TileGrid, or VectorIO is present. In this library, this was causing previous values in the result_buffer to be recopied to the output bitmap file whenever a "un-owned" pixel is observed. This reinitializes the `result_buffer` to be sure that any "un-owned" pixels are made black in the output bitmap file. Resolves issue: https://github.com/adafruit/Adafruit_CircuitPython_BitmapSaver/issues/8 --- adafruit_bitmapsaver.py | 1 + 1 file changed, 1 insertion(+) diff --git a/adafruit_bitmapsaver.py b/adafruit_bitmapsaver.py index 8669bfc..32eab17 100644 --- a/adafruit_bitmapsaver.py +++ b/adafruit_bitmapsaver.py @@ -91,6 +91,7 @@ def _write_pixels(output_file, pixel_source, palette): color >>= 8 buffer_index += 1 else: + result_buffer = bytearray(2048) data = pixel_source.fill_row(y - 1, result_buffer) for i in range(width): pixel565 = (data[i * 2] << 8) + data[i * 2 + 1] From fd43f346c08bb2e55e6a91b415ea7c5bb680ca37 Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Tue, 2 Mar 2021 22:28:39 -0600 Subject: [PATCH 2/3] Update reinit of result_buffer --- adafruit_bitmapsaver.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/adafruit_bitmapsaver.py b/adafruit_bitmapsaver.py index 32eab17..ce1c512 100644 --- a/adafruit_bitmapsaver.py +++ b/adafruit_bitmapsaver.py @@ -99,6 +99,8 @@ def _write_pixels(output_file, pixel_source, palette): row_buffer[buffer_index] = b & 0xFF buffer_index += 1 output_file.write(row_buffer) + for i in range(width * 2): + result_buffer[i] = 0 gc.collect() From 3e68289eb35bb48eef266e4e11e5eab6fe6bcf38 Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Wed, 3 Mar 2021 10:42:22 -0600 Subject: [PATCH 3/3] Delete unnecesary line --- adafruit_bitmapsaver.py | 1 - 1 file changed, 1 deletion(-) diff --git a/adafruit_bitmapsaver.py b/adafruit_bitmapsaver.py index ce1c512..f889105 100644 --- a/adafruit_bitmapsaver.py +++ b/adafruit_bitmapsaver.py @@ -91,7 +91,6 @@ def _write_pixels(output_file, pixel_source, palette): color >>= 8 buffer_index += 1 else: - result_buffer = bytearray(2048) data = pixel_source.fill_row(y - 1, result_buffer) for i in range(width): pixel565 = (data[i * 2] << 8) + data[i * 2 + 1]