diff options
author | Stefan Kerkmann <karlk90@pm.me> | 2022-04-17 00:30:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-17 08:30:51 +1000 |
commit | 147e57fd5930a1c18596a2401c9ee6f30730b86f (patch) | |
tree | 78ee2b0ae01b76d1e251d64927c8039a818fd567 | |
parent | 5841c755ae0b5629deb4c139eb535a82437112a2 (diff) |
[QP] Check BPP capabilities before loading the palette (#16863)
-rw-r--r-- | quantum/painter/qp_draw_image.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/quantum/painter/qp_draw_image.c b/quantum/painter/qp_draw_image.c index 5134ae7e99..5822758dce 100644 --- a/quantum/painter/qp_draw_image.c +++ b/quantum/painter/qp_draw_image.c @@ -131,6 +131,12 @@ static bool qp_drawimage_prepare_frame_for_stream_read(painter_device_t device, // Ensure we aren't reusing any palette qp_internal_invalidate_palette(); + if (!qp_internal_bpp_capable(info->bpp)) { + qp_dprintf("qp_drawimage_recolor: fail (image bpp too high (%d), check QUANTUM_PAINTER_SUPPORTS_256_PALETTE)\n", (int)info->bpp); + qp_comms_stop(device); + return false; + } + // Handle palette if needed const uint16_t palette_entries = 1u << info->bpp; bool needs_pixconvert = false; @@ -146,12 +152,6 @@ static bool qp_drawimage_prepare_frame_for_stream_read(painter_device_t device, needs_pixconvert = qp_internal_interpolate_palette(fg_hsv888, bg_hsv888, palette_entries); } - if (!qp_internal_bpp_capable(info->bpp)) { - qp_dprintf("qp_drawimage_recolor: fail (image bpp too high (%d), check QUANTUM_PAINTER_SUPPORTS_256_PALETTE)\n", (int)info->bpp); - qp_comms_stop(device); - return false; - } - if (needs_pixconvert) { // Convert the palette to native format if (!driver->driver_vtable->palette_convert(device, palette_entries, qp_internal_global_pixel_lookup_table)) { |