From 20d2cbc68fdc7f7c8c3305fefe16216dbe96c10d Mon Sep 17 00:00:00 2001 From: "J.B. Langston" Date: Sat, 1 Feb 2020 14:39:05 -0600 Subject: [PATCH] Fix clear screen alpha channel --- src/util/image.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/util/image.cpp b/src/util/image.cpp index 9de04b98..b367b8dc 100644 --- a/src/util/image.cpp +++ b/src/util/image.cpp @@ -240,7 +240,6 @@ void destroy_image(struct image *img) void clear_image(struct image *img) { - int i; int color = img->palette->pixels[0]; int width = img->width * img->bytesperpixel; if (img->palette->npreallocated) @@ -250,8 +249,13 @@ void clear_image(struct image *img) if (color) color = 255; } - for (i = 0; i < img->height; i++) - memset(img->currlines[i], color, width); + for (int i = 0; i < img->height; i++) + for (int j = 0; j < width; j++) { + if (j % img->bytesperpixel == img->palette->info.truec.missingbyte) + img->currlines[i][j] = 0xff; + else + img->currlines[i][j] = color; + } } #define drawchar drawchar8