Skip to content

Commit b816a29

Browse files
Finomnisnashif
authored andcommitted
drivers: display_sdl: fix incorrect color conversion
Non-alpha colors were converted to colors with `0x00` alpha, which makes them fully transparent. The correct way would be to add a `0xff` alpha, which this change does. Signed-off-by: Martin Stumpf <[email protected]>
1 parent 02d562e commit b816a29

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/display/display_sdl.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static void sdl_display_write_rgb888(uint8_t *disp_buf,
123123
pixel = *byte_ptr << 16;
124124
pixel |= *(byte_ptr + 1) << 8;
125125
pixel |= *(byte_ptr + 2);
126-
*((uint32_t *)disp_buf) = pixel;
126+
*((uint32_t *)disp_buf) = pixel | 0xFF000000;
127127
disp_buf += 4;
128128
}
129129
}
@@ -149,7 +149,7 @@ static void sdl_display_write_rgb565(uint8_t *disp_buf,
149149
pixel = (((rgb565 >> 11) & 0x1F) * 255 / 31) << 16;
150150
pixel |= (((rgb565 >> 5) & 0x3F) * 255 / 63) << 8;
151151
pixel |= (rgb565 & 0x1F) * 255 / 31;
152-
*((uint32_t *)disp_buf) = pixel;
152+
*((uint32_t *)disp_buf) = pixel | 0xFF000000;
153153
disp_buf += 4;
154154
}
155155
}
@@ -173,7 +173,7 @@ static void sdl_display_write_bgr565(uint8_t *disp_buf,
173173
pixel = (((*pix_ptr >> 11) & 0x1F) * 255 / 31) << 16;
174174
pixel |= (((*pix_ptr >> 5) & 0x3F) * 255 / 63) << 8;
175175
pixel |= (*pix_ptr & 0x1F) * 255 / 31;
176-
*((uint32_t *)disp_buf) = pixel;
176+
*((uint32_t *)disp_buf) = pixel | 0xFF000000;
177177
disp_buf += 4;
178178
}
179179
}
@@ -211,9 +211,9 @@ static void sdl_display_write_mono(uint8_t *disp_buf,
211211
if ((*byte_ptr & mono_pixel_order(h_idx)) != 0U) {
212212
pixel = one_color;
213213
} else {
214-
pixel = (~one_color) & 0x00FFFFFF;
214+
pixel = ~one_color;
215215
}
216-
*((uint32_t *)disp_buf) = pixel;
216+
*((uint32_t *)disp_buf) = pixel | 0xFF000000;
217217
disp_buf += (desc->width * 4U);
218218
}
219219
disp_buf = disp_buf_start;

0 commit comments

Comments
 (0)