fix: Skip negative screen coordinates only after we read the bitmap row. (#431)
Otherwise, we don't crop properly. Fixes #430 ### AI Usage Did you use AI tools to help write this code? _**< NO >**_
This commit is contained in:
@@ -201,9 +201,6 @@ void GfxRenderer::drawBitmap(const Bitmap& bitmap, const int x, const int y, con
|
|||||||
if (screenY >= getScreenHeight()) {
|
if (screenY >= getScreenHeight()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (screenY < 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bitmap.readNextRow(outputRow, rowBytes) != BmpReaderError::Ok) {
|
if (bitmap.readNextRow(outputRow, rowBytes) != BmpReaderError::Ok) {
|
||||||
Serial.printf("[%lu] [GFX] Failed to read row %d from bitmap\n", millis(), bmpY);
|
Serial.printf("[%lu] [GFX] Failed to read row %d from bitmap\n", millis(), bmpY);
|
||||||
@@ -212,6 +209,10 @@ void GfxRenderer::drawBitmap(const Bitmap& bitmap, const int x, const int y, con
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (screenY < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (bmpY < cropPixY) {
|
if (bmpY < cropPixY) {
|
||||||
// Skip the row if it's outside the crop area
|
// Skip the row if it's outside the crop area
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ void SleepActivity::renderBitmapSleepScreen(const Bitmap& bitmap) const {
|
|||||||
Serial.printf("[%lu] [SLP] Cropping bitmap y: %f\n", millis(), cropY);
|
Serial.printf("[%lu] [SLP] Cropping bitmap y: %f\n", millis(), cropY);
|
||||||
ratio = static_cast<float>(bitmap.getWidth()) / ((1.0f - cropY) * static_cast<float>(bitmap.getHeight()));
|
ratio = static_cast<float>(bitmap.getWidth()) / ((1.0f - cropY) * static_cast<float>(bitmap.getHeight()));
|
||||||
}
|
}
|
||||||
x = std::round((pageWidth - pageHeight * ratio) / 2);
|
x = std::round((static_cast<float>(pageWidth) - static_cast<float>(pageHeight) * ratio) / 2);
|
||||||
y = 0;
|
y = 0;
|
||||||
Serial.printf("[%lu] [SLP] Centering with ratio %f to x=%d\n", millis(), ratio, x);
|
Serial.printf("[%lu] [SLP] Centering with ratio %f to x=%d\n", millis(), ratio, x);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user