[Horus] Problem when resizing transparent bitmaps
This commit is contained in:
@@ -28,12 +28,12 @@ void BitmapBuffer::drawAlphaPixel(display_t * p, uint8_t opacity, uint16_t color
|
||||
}
|
||||
else if (opacity != 0) {
|
||||
uint8_t bgWeight = OPACITY_MAX - opacity;
|
||||
COLOR_SPLIT(color, red, green, blue);
|
||||
COLOR_SPLIT(*p, bgRed, bgGreen, bgBlue);
|
||||
RGB_SPLIT(color, red, green, blue);
|
||||
RGB_SPLIT(*p, bgRed, bgGreen, bgBlue);
|
||||
uint16_t r = (bgRed * bgWeight + red * opacity) / OPACITY_MAX;
|
||||
uint16_t g = (bgGreen * bgWeight + green * opacity) / OPACITY_MAX;
|
||||
uint16_t b = (bgBlue * bgWeight + blue * opacity) / OPACITY_MAX;
|
||||
drawPixel(p, COLOR_JOIN(r, g, b));
|
||||
drawPixel(p, RGB_JOIN(r, g, b));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,14 +123,14 @@ void BitmapBuffer::drawFilledRect(coord_t x, coord_t y, coord_t w, coord_t h, ui
|
||||
void BitmapBuffer::invertRect(coord_t x, coord_t y, coord_t w, coord_t h, LcdFlags att)
|
||||
{
|
||||
display_t color = lcdColorTable[COLOR_IDX(att)];
|
||||
COLOR_SPLIT(color, red, green, blue);
|
||||
RGB_SPLIT(color, red, green, blue);
|
||||
|
||||
for (int i=y; i<y+h; i++) {
|
||||
display_t * p = getPixelPtr(x, i);
|
||||
for (int j=0; j<w; j++) {
|
||||
// TODO ASSERT_IN_DISPLAY(p);
|
||||
COLOR_SPLIT(*p, bgRed, bgGreen, bgBlue);
|
||||
drawPixel(p++, COLOR_JOIN(0x1F + red - bgRed, 0x3F + green - bgGreen, 0x1F + blue - bgBlue));
|
||||
RGB_SPLIT(*p, bgRed, bgGreen, bgBlue);
|
||||
drawPixel(p++, RGB_JOIN(0x1F + red - bgRed, 0x3F + green - bgGreen, 0x1F + blue - bgBlue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +238,13 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
||||
const uint16_t * qstart = &bmp->getData()[(srcy + int(i / scale)) * bmp->getWidth() + srcx];
|
||||
for (int j = 0; j < scaledw; j++) {
|
||||
const uint16_t * q = qstart + int(j / scale);
|
||||
*p = *q;
|
||||
if (bmp->getFormat() == BMP_ARGB4444) {
|
||||
ARGB_SPLIT(*q, a, r, g, b);
|
||||
drawAlphaPixel(p, a, RGB_JOIN(r<<1, g<<2, b<<1));
|
||||
}
|
||||
else {
|
||||
drawPixel(p, *q);
|
||||
}
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,12 +107,18 @@ extern uint16_t lcdColorTable[LCD_COLOR_COUNT];
|
||||
#define OVERLAY_COLOR COLOR(OVERLAY_COLOR_INDEX)
|
||||
#define CUSTOM_COLOR COLOR(CUSTOM_COLOR_INDEX)
|
||||
|
||||
#define COLOR_SPLIT(color, r, g, b) \
|
||||
#define ARGB_SPLIT(color, a, r, g, b) \
|
||||
uint16_t a = ((color) & 0xF000) >> 12; \
|
||||
uint16_t r = ((color) & 0x0F00) >> 8; \
|
||||
uint16_t g = ((color) & 0x00F0) >> 4; \
|
||||
uint16_t b = ((color) & 0x000F)
|
||||
|
||||
#define RGB_SPLIT(color, r, g, b) \
|
||||
uint16_t r = ((color) & 0xF800) >> 11; \
|
||||
uint16_t g = ((color) & 0x07E0) >> 5; \
|
||||
uint16_t b = ((color) & 0x001F)
|
||||
|
||||
#define COLOR_JOIN(r, g, b) \
|
||||
#define RGB_JOIN(r, g, b) \
|
||||
(((r) << 11) + ((g) << 5) + (b))
|
||||
|
||||
#define GET_RED(color) \
|
||||
|
||||
@@ -126,7 +126,7 @@ bool editZoneOption(coord_t y, const ZoneOption * option, ZoneOptionValue * valu
|
||||
}
|
||||
}
|
||||
else if (option->type == ZoneOption::Color) {
|
||||
COLOR_SPLIT(value->unsignedValue, r, g, b);
|
||||
RGB_SPLIT(value->unsignedValue, r, g, b);
|
||||
|
||||
lcdSetColor(value->unsignedValue);
|
||||
lcdDrawSolidFilledRect(SCREENS_SETUP_2ND_COLUMN-1, y+1, 42, 17, TEXT_COLOR);
|
||||
@@ -148,7 +148,7 @@ bool editZoneOption(coord_t y, const ZoneOption * option, ZoneOptionValue * valu
|
||||
b = checkIncDec(event, b, 0, (1<<5)-1, i_flags);
|
||||
}
|
||||
if (attr && checkIncDec_Ret) {
|
||||
value->unsignedValue = COLOR_JOIN(r, g, b);
|
||||
value->unsignedValue = RGB_JOIN(r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user