@@ -54,25 +54,30 @@ namespace pimoroni {
54
54
uint16_t dest = *pdest;
55
55
uint8_t alpha = *palpha >> 3 ;
56
56
57
- // blend tha pixel
58
- // expand the pen colour to provide space to multiple all
59
- // channels at once
60
- uint32_t cs = 0 ;
61
- cs |= ((color & 0b1111100000000000 ) << 11 ); // red
62
- cs |= ((color & 0b0000011111100000 ) << 5 ); // green
63
- cs |= ((color & 0b0000000000011111 ) ); // blue
57
+ if (alpha == 255 ) {
58
+ *pdest = color;
59
+ }if (alpha == 0 ) {
60
+ }else {
61
+ // blend tha pixel
62
+ // expand the pen colour to provide space to multiple all
63
+ // channels at once
64
+ uint32_t cs = 0 ;
65
+ cs |= ((color & 0b1111100000000000 ) << 11 ); // red
66
+ cs |= ((color & 0b0000011111100000 ) << 5 ); // green
67
+ cs |= ((color & 0b0000000000011111 ) ); // blue
64
68
65
- uint32_t cd = 0 ;
66
- cd |= ((dest & 0b1111100000000000 ) << 11 ); // red
67
- cd |= ((dest & 0b0000011111100000 ) << 5 ); // green
68
- cd |= ((dest & 0b0000000000011111 ) ); // blue
69
+ uint32_t cd = 0 ;
70
+ cd |= ((dest & 0b1111100000000000 ) << 11 ); // red
71
+ cd |= ((dest & 0b0000011111100000 ) << 5 ); // green
72
+ cd |= ((dest & 0b0000000000011111 ) ); // blue
69
73
70
- uint32_t cr = ((cs * alpha) + (cd * (31 - alpha)))>> 5 ;
74
+ uint32_t cr = ((cs * alpha) + (cd * (31 - alpha)))>> 5 ;
71
75
72
- // recombine the channels
73
- *pdest = ((cr >> 27 ) & 0b1111100000000000 );
74
- *pdest |= ((cr >> 11 ) & 0b0000011111100000 );
75
- *pdest |= ((cr >> 5 ) & 0b0000000000011111 );
76
+ // recombine the channels
77
+ *pdest = ((cr >> 27 ) & 0b1111100000000000 );
78
+ *pdest |= ((cr >> 11 ) & 0b0000011111100000 );
79
+ *pdest |= ((cr >> 5 ) & 0b0000000000011111 );
80
+ }
76
81
77
82
pdest++;
78
83
palpha++;
0 commit comments