Skip to content

Commit 8117066

Browse files
committed
PicoVector: Fix bug in RGB888 blend.
Move the source pen out for a tiny performance boost.
1 parent 7a894dc commit 8117066

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

libraries/pico_graphics/pico_graphics_pen_rgb888.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,24 @@ namespace pimoroni {
3737
}
3838
}
3939
bool PicoGraphics_PenRGB888::render_tile(const Tile *tile) {
40+
// Unpack our pen colour
41+
uint32_t sr = (color >> 16) & 0xff;
42+
uint32_t sg = (color >> 8) & 0xff;
43+
uint32_t sb = (color >> 0) & 0xff;
44+
4045
for(int y = 0; y < tile->h; y++) {
4146
uint8_t *p_alpha = &tile->data[(y * tile->stride)];
4247
uint32_t *p_dest = &((uint32_t *)frame_buffer)[tile->x + ((tile->y + y) * bounds.w)];
4348
for(int x = 0; x < tile->w; x++) {
44-
uint16_t dest = *p_dest;
49+
uint32_t dest = *p_dest;
4550
uint8_t alpha = *p_alpha;
4651

4752
// TODO: Alpha blending
4853
if(alpha == 255) {
4954
*p_dest = color;
5055
}else if(alpha == 0) {
5156
} else {
52-
// blend tha pixel
53-
uint32_t sr = (color >> 16) & 0xff;
54-
uint32_t sg = (color >> 8) & 0xff;
55-
uint32_t sb = (color >> 0) & 0xff;
56-
57+
// blend the pixel
5758
uint32_t dr = (dest >> 16) & 0xff;
5859
uint32_t dg = (dest >> 8) & 0xff;
5960
uint32_t db = (dest >> 0) & 0xff;

0 commit comments

Comments
 (0)