From db40bd05acea5a459c6aa43d037e65c40fb0e050 Mon Sep 17 00:00:00 2001 From: elpekenin Date: Thu, 2 Mar 2023 22:14:06 +0100 Subject: [PATCH 1/2] Initial code --- quantum/painter/qp_draw_image.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/quantum/painter/qp_draw_image.c b/quantum/painter/qp_draw_image.c index fa806172420b..4e39767e93bf 100644 --- a/quantum/painter/qp_draw_image.c +++ b/quantum/painter/qp_draw_image.c @@ -273,6 +273,11 @@ static bool qp_drawimage_recolor_impl(painter_device_t device, uint16_t x, uint1 if (ret && output_state.pixel_write_pos > 0) { ret &= driver->driver_vtable->pixdata(device, qp_internal_global_pixdata_buffer, output_state.pixel_write_pos); } + } + else if (frame_info->bpp != driver->native_bits_per_pixel) { + // Prevent stuff like drawing 24bpp images on 16bpp displays + qp_dprintf("Image's bpp doesn't match the target display's native_bits_per_pixel\n"); + return false; } else { // Set up the output state struct qp_internal_byte_output_state output_state = {.device = device, .byte_write_pos = 0, .max_bytes = qp_internal_num_pixels_in_buffer(device) * driver->native_bits_per_pixel / 8}; From d62529e18715ed4edbca227de0b384898fa555c8 Mon Sep 17 00:00:00 2001 From: elpekenin Date: Thu, 2 Mar 2023 22:46:04 +0100 Subject: [PATCH 2/2] Yet another un-formatted PR --- quantum/painter/qp_draw_image.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/quantum/painter/qp_draw_image.c b/quantum/painter/qp_draw_image.c index 4e39767e93bf..073f1da8ebfd 100644 --- a/quantum/painter/qp_draw_image.c +++ b/quantum/painter/qp_draw_image.c @@ -273,8 +273,7 @@ static bool qp_drawimage_recolor_impl(painter_device_t device, uint16_t x, uint1 if (ret && output_state.pixel_write_pos > 0) { ret &= driver->driver_vtable->pixdata(device, qp_internal_global_pixdata_buffer, output_state.pixel_write_pos); } - } - else if (frame_info->bpp != driver->native_bits_per_pixel) { + } else if (frame_info->bpp != driver->native_bits_per_pixel) { // Prevent stuff like drawing 24bpp images on 16bpp displays qp_dprintf("Image's bpp doesn't match the target display's native_bits_per_pixel\n"); return false;