Add horizontalFlip() and verticalFlip() to BitmapBuffer
This commit is contained in:
@@ -676,6 +676,32 @@ BitmapBuffer * BitmapBuffer::loadMask(const char * filename)
|
|||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BitmapBuffer * BitmapBuffer::horizontalFlip() const
|
||||||
|
{
|
||||||
|
BitmapBuffer * result = new BitmapBuffer(format, width(), height());
|
||||||
|
pixel_t * srcData = data;
|
||||||
|
pixel_t * destData = result->data;
|
||||||
|
for (uint8_t y = 0; y < height(); y++) {
|
||||||
|
for (uint8_t x = 0; x < width(); x++) {
|
||||||
|
destData[x] = srcData[width() - 1 - x];
|
||||||
|
}
|
||||||
|
srcData += width();
|
||||||
|
destData += width();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
BitmapBuffer * BitmapBuffer::verticalFlip() const
|
||||||
|
{
|
||||||
|
BitmapBuffer * result = new BitmapBuffer(format, width(), height());
|
||||||
|
for (uint8_t y = 0; y < height(); y++) {
|
||||||
|
for (uint8_t x = 0; x < width(); x++) {
|
||||||
|
result->data[y * width() + x] = data[(height() - 1 - y) * width() + x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
BitmapBuffer * BitmapBuffer::loadMaskOnBackground(const char * filename, LcdFlags foreground, LcdFlags background)
|
BitmapBuffer * BitmapBuffer::loadMaskOnBackground(const char * filename, LcdFlags foreground, LcdFlags background)
|
||||||
{
|
{
|
||||||
BitmapBuffer * result = nullptr;
|
BitmapBuffer * result = nullptr;
|
||||||
|
|||||||
+5
-1
@@ -232,7 +232,7 @@ class RLEBitmap:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
class BitmapBuffer: public BitmapBufferBase<pixel_t>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
bool dataAllocated;
|
bool dataAllocated;
|
||||||
@@ -500,6 +500,10 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
|||||||
drawBitmap(x + xshift, y + yshift, bitmap, 0, 0, 0, 0, scale);
|
drawBitmap(x + xshift, y + yshift, bitmap, 0, 0, 0, 0, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BitmapBuffer * horizontalFlip() const;
|
||||||
|
|
||||||
|
BitmapBuffer * verticalFlip() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static BitmapBuffer * load_bmp(const char * filename);
|
static BitmapBuffer * load_bmp(const char * filename);
|
||||||
static BitmapBuffer * load_stb(const char * filename);
|
static BitmapBuffer * load_stb(const char * filename);
|
||||||
|
|||||||
Reference in New Issue
Block a user