@@ -24,6 +24,15 @@
|
||||
#include <inttypes.h>
|
||||
#include "colors.h"
|
||||
|
||||
#if defined(PCBX10)
|
||||
#define MOVE_PIXEL_RIGHT(p, count) p -= count
|
||||
#else
|
||||
#define MOVE_PIXEL_RIGHT(p, count) p += count
|
||||
#endif
|
||||
|
||||
#define MOVE_TO_NEXT_RIGHT_PIXEL(p) MOVE_PIXEL_RIGHT(p, 1)
|
||||
|
||||
|
||||
#define USE_STB
|
||||
|
||||
// TODO should go to lcd.h again
|
||||
@@ -70,6 +79,15 @@ class BitmapBufferBase
|
||||
return data;
|
||||
}
|
||||
|
||||
inline const display_t * getPixelPtr(coord_t x, coord_t y) const
|
||||
{
|
||||
#if defined(PCBX10)
|
||||
x = width - x - 1;
|
||||
y = height - y - 1;
|
||||
#endif
|
||||
return &data[y*width + x];
|
||||
}
|
||||
|
||||
protected:
|
||||
uint8_t format;
|
||||
uint16_t width;
|
||||
@@ -140,8 +158,21 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
||||
#endif
|
||||
}
|
||||
|
||||
inline const display_t * getPixelPtr(coord_t x, coord_t y) const
|
||||
{
|
||||
#if defined(PCBX10)
|
||||
x = width - x - 1;
|
||||
y = height - y - 1;
|
||||
#endif
|
||||
return &data[y*width + x];
|
||||
}
|
||||
|
||||
inline display_t * getPixelPtr(coord_t x, coord_t y)
|
||||
{
|
||||
#if defined(PCBX10)
|
||||
x = width - x - 1;
|
||||
y = height - y - 1;
|
||||
#endif
|
||||
return &data[y*width + x];
|
||||
}
|
||||
|
||||
@@ -180,7 +211,7 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
||||
if (!data || h==0 || w==0) return;
|
||||
if (h<0) { y+=h; h=-h; }
|
||||
if (w<0) { x+=w; w=-w; }
|
||||
DMAFillRect(data, width, x, y, w, h, lcdColorTable[COLOR_IDX(flags)]);
|
||||
DMAFillRect(data, width, height, x, y, w, h, lcdColorTable[COLOR_IDX(flags)]);
|
||||
}
|
||||
|
||||
void drawFilledRect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat, LcdFlags att);
|
||||
@@ -242,10 +273,10 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
||||
h = height - y;
|
||||
}
|
||||
if (bmp->getFormat() == BMP_ARGB4444) {
|
||||
DMACopyAlphaBitmap(data, this->width, x, y, bmp->getData(), srcw, srcx, srcy, w, h);
|
||||
DMACopyAlphaBitmap(data, width, height, x, y, bmp->getData(), srcw, srch, srcx, srcy, w, h);
|
||||
}
|
||||
else {
|
||||
DMACopyBitmap(data, width, x, y, bmp->getData(), srcw, srcx, srcy, w, h);
|
||||
DMACopyBitmap(data, width, height, x, y, bmp->getData(), srcw, srch, srcx, srcy, w, h);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -258,10 +289,11 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
||||
scaledh = height - y;
|
||||
|
||||
for (int i = 0; i < scaledh; i++) {
|
||||
uint16_t * p = &data[(y + i) * width + x];
|
||||
const uint16_t * qstart = &bmp->getData()[(srcy + int(i / scale)) * bmp->getWidth() + srcx];
|
||||
display_t * p = getPixelPtr(x, y + i);
|
||||
const display_t * qstart = bmp->getPixelPtr(srcx, srcy + int(i / scale));
|
||||
for (int j = 0; j < scaledw; j++) {
|
||||
const uint16_t * q = qstart + int(j / scale);
|
||||
const display_t * q = qstart;
|
||||
MOVE_PIXEL_RIGHT(q, int(j / scale));
|
||||
if (bmp->getFormat() == BMP_ARGB4444) {
|
||||
ARGB_SPLIT(*q, a, r, g, b);
|
||||
drawAlphaPixel(p, a, RGB_JOIN(r<<1, g<<2, b<<1));
|
||||
@@ -269,7 +301,7 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
||||
else {
|
||||
drawPixel(p, *q);
|
||||
}
|
||||
p++;
|
||||
MOVE_TO_NEXT_RIGHT_PIXEL(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user