@@ -49,7 +49,7 @@ void BitmapBuffer::drawHorizontalLine(coord_t x, coord_t y, coord_t w, uint8_t p
|
||||
if (pat == SOLID) {
|
||||
while (w--) {
|
||||
drawAlphaPixel(p, opacity, color);
|
||||
p++;
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(p);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -61,7 +61,7 @@ void BitmapBuffer::drawHorizontalLine(coord_t x, coord_t y, coord_t w, uint8_t p
|
||||
else {
|
||||
pat = pat >> 1;
|
||||
}
|
||||
p++;
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,7 +130,8 @@ void BitmapBuffer::invertRect(coord_t x, coord_t y, coord_t w, coord_t h, LcdFla
|
||||
for (int j=0; j<w; j++) {
|
||||
// TODO ASSERT_IN_DISPLAY(p);
|
||||
RGB_SPLIT(*p, bgRed, bgGreen, bgBlue);
|
||||
drawPixel(p++, RGB_JOIN(0x1F + red - bgRed, 0x3F + green - bgGreen, 0x1F + blue - bgBlue));
|
||||
drawPixel(p, RGB_JOIN(0x1F + red - bgRed, 0x3F + green - bgGreen, 0x1F + blue - bgBlue));
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,7 +257,8 @@ void BitmapBuffer::drawMask(coord_t x, coord_t y, BitmapBuffer * mask, LcdFlags
|
||||
display_t * q = mask->getPixelPtr(offset, row);
|
||||
for (coord_t col=0; col<width; col++) {
|
||||
drawAlphaPixel(p, *((uint8_t *)q), color);
|
||||
p++; q++;
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(p);
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(q);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -489,10 +491,10 @@ BitmapBuffer * BitmapBuffer::loadMask(const char * filename)
|
||||
{
|
||||
BitmapBuffer * bitmap = BitmapBuffer::load(filename);
|
||||
if (bitmap) {
|
||||
display_t * p = bitmap->getData();
|
||||
display_t * p = bitmap->getPixelPtr(0, 0);
|
||||
for (int i = bitmap->getWidth() * bitmap->getHeight(); i > 0; i--) {
|
||||
*((uint8_t *)p) = OPACITY_MAX - ((*p) >> 12);
|
||||
p++;
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(p);
|
||||
}
|
||||
}
|
||||
return bitmap;
|
||||
@@ -624,14 +626,13 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint16_t * dest = bmp->getData();
|
||||
uint32_t rowSize;
|
||||
bool hasAlpha = false;
|
||||
|
||||
switch (depth) {
|
||||
case 32:
|
||||
for (int i=h-1; i>=0; i--) {
|
||||
uint8_t * dst = ((uint8_t *)dest) + i*w*2;
|
||||
display_t * dst = bmp->getPixelPtr(0, i);
|
||||
for (unsigned int j=0; j<w; j++) {
|
||||
uint32_t pixel;
|
||||
result = f_read(&imgFile, (uint8_t *)&pixel, 4, &read);
|
||||
@@ -641,23 +642,23 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
|
||||
return NULL;
|
||||
}
|
||||
if (hasAlpha) {
|
||||
*((uint16_t *)dst) = ARGB(pixel & 0xff, (pixel >> 24) & 0xff, (pixel >> 16) & 0xff, (pixel >> 8) & 0xff);
|
||||
*dst = ARGB(pixel & 0xff, (pixel >> 24) & 0xff, (pixel >> 16) & 0xff, (pixel >> 8) & 0xff);
|
||||
}
|
||||
else {
|
||||
if ((pixel & 0xff) == 0xff) {
|
||||
*((uint16_t *)dst) = RGB(pixel >> 24, (pixel >> 16) & 0xff, (pixel >> 8) & 0xff);
|
||||
*dst = RGB(pixel >> 24, (pixel >> 16) & 0xff, (pixel >> 8) & 0xff);
|
||||
}
|
||||
else {
|
||||
hasAlpha = true;
|
||||
bmp->setFormat(BMP_ARGB4444);
|
||||
for (uint16_t * p = dest + i*w; p<dest + h*w; p++) {
|
||||
uint16_t tmp = *p;
|
||||
for (display_t * p = bmp->getPixelPtr(j, i); p != bmp->getPixelPtr(0, h); MOVE_TO_NEXT_RIGHT_PIXEL(p)) {
|
||||
display_t tmp = *p;
|
||||
*p = ((tmp >> 1) & 0x0f) + (((tmp >> 7) & 0x0f) << 4) + (((tmp >> 12) & 0x0f) << 8);
|
||||
}
|
||||
*((uint16_t *)dst) = ARGB(pixel & 0xff, (pixel >> 24) & 0xff, (pixel >> 16) & 0xff, (pixel >> 8) & 0xff);
|
||||
*dst = ARGB(pixel & 0xff, (pixel >> 24) & 0xff, (pixel >> 16) & 0xff, (pixel >> 8) & 0xff);
|
||||
}
|
||||
}
|
||||
dst += 2;
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(dst);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -674,12 +675,12 @@ BitmapBuffer * BitmapBuffer::load_bmp(const char * filename)
|
||||
delete bmp;
|
||||
return NULL;
|
||||
}
|
||||
uint8_t * dst = ((uint8_t *)dest) + i*w*2;
|
||||
display_t * dst = bmp->getPixelPtr(0, i);
|
||||
for (uint32_t j=0; j<w; j++) {
|
||||
uint8_t index = (buf[j/2] >> ((j & 1) ? 0 : 4)) & 0x0F;
|
||||
uint8_t val = palette[index];
|
||||
*((uint16_t *)dst) = RGB(val, val, val);
|
||||
dst += 2;
|
||||
*dst = RGB(val, val, val);
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(dst);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -792,22 +793,22 @@ BitmapBuffer * BitmapBuffer::load_stb(const char * filename)
|
||||
#if 0
|
||||
DMABitmapConvert(bmp->data, img, w, h, n == 4 ? DMA2D_ARGB4444 : DMA2D_RGB565);
|
||||
#else
|
||||
uint16_t * dest = bmp->getData();
|
||||
display_t * dest = bmp->getPixelPtr(0, 0);
|
||||
const uint8_t * p = img;
|
||||
if (n == 4) {
|
||||
for(int row = 0; row < h; ++row) {
|
||||
for(int col = 0; col < w; ++col) {
|
||||
for (int row = 0; row < h; ++row) {
|
||||
for (int col = 0; col < w; ++col) {
|
||||
*dest = ARGB(p[3], p[0], p[1], p[2]);
|
||||
++dest;
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(dest);
|
||||
p += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(int row = 0; row < h; ++row) {
|
||||
for(int col = 0; col < w; ++col) {
|
||||
for (int row = 0; row < h; ++row) {
|
||||
for (int col = 0; col < w; ++col) {
|
||||
*dest = RGB(p[0], p[1], p[2]);
|
||||
++dest;
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(dest);
|
||||
p += 4;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user