Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QP] Check BPP capabilities before loading the palette #16863

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions quantum/painter/qp_draw_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)) {
Expand Down