nice
This commit is contained in:
@@ -153,10 +153,10 @@ void GfxRenderer::drawImage(const uint8_t bitmap[], const int x, const int y, co
|
||||
}
|
||||
|
||||
void GfxRenderer::drawBitmap(const Bitmap& bitmap, const int x, const int y, const int maxWidth, const int maxHeight,
|
||||
const float cropX, const float cropY) const {
|
||||
const float cropX, const float cropY, const bool invert) const {
|
||||
// For 1-bit bitmaps, use optimized 1-bit rendering path (no crop support for 1-bit)
|
||||
if (bitmap.is1Bit() && cropX == 0.0f && cropY == 0.0f) {
|
||||
drawBitmap1Bit(bitmap, x, y, maxWidth, maxHeight);
|
||||
drawBitmap1Bit(bitmap, x, y, maxWidth, maxHeight, invert);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ void GfxRenderer::drawBitmap(const Bitmap& bitmap, const int x, const int y, con
|
||||
}
|
||||
|
||||
void GfxRenderer::drawBitmap1Bit(const Bitmap& bitmap, const int x, const int y, const int maxWidth,
|
||||
const int maxHeight) const {
|
||||
const int maxHeight, const bool invert) const {
|
||||
float scale = 1.0f;
|
||||
|
||||
// Calculate scale to fit within maxWidth/maxHeight (supports both up and down scaling)
|
||||
@@ -324,8 +324,12 @@ void GfxRenderer::drawBitmap1Bit(const Bitmap& bitmap, const int x, const int y,
|
||||
const uint8_t val = outputRow[bmpX / 4] >> (6 - ((bmpX * 2) % 8)) & 0x3;
|
||||
|
||||
// For 1-bit source: 0 or 1 -> map to black (0,1,2) or white (3)
|
||||
// val < 3 means black pixel (draw it)
|
||||
if (val < 3) {
|
||||
// val < 3 means black pixel, val == 3 means white pixel
|
||||
// When inverted: draw white pixels as black, skip black pixels
|
||||
const bool isBlackPixel = (val < 3);
|
||||
const bool shouldDraw = invert ? !isBlackPixel : isBlackPixel;
|
||||
|
||||
if (shouldDraw) {
|
||||
// Draw to all X positions this source pixel maps to (for upscaling, this fills gaps)
|
||||
for (int screenX = screenXStart; screenX < screenXEnd; screenX++) {
|
||||
if (screenX < 0) continue;
|
||||
@@ -333,7 +337,6 @@ void GfxRenderer::drawBitmap1Bit(const Bitmap& bitmap, const int x, const int y,
|
||||
drawPixel(screenX, screenY, true);
|
||||
}
|
||||
}
|
||||
// White pixels (val == 3) are not drawn (leave background)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,8 +67,8 @@ class GfxRenderer {
|
||||
void fillRect(int x, int y, int width, int height, bool state = true) const;
|
||||
void drawImage(const uint8_t bitmap[], int x, int y, int width, int height) const;
|
||||
void drawBitmap(const Bitmap& bitmap, int x, int y, int maxWidth, int maxHeight, float cropX = 0,
|
||||
float cropY = 0) const;
|
||||
void drawBitmap1Bit(const Bitmap& bitmap, int x, int y, int maxWidth, int maxHeight) const;
|
||||
float cropY = 0, bool invert = false) const;
|
||||
void drawBitmap1Bit(const Bitmap& bitmap, int x, int y, int maxWidth, int maxHeight, bool invert = false) const;
|
||||
void fillPolygon(const int* xPoints, const int* yPoints, int numPoints, bool state = true) const;
|
||||
|
||||
// Text
|
||||
|
||||
Reference in New Issue
Block a user