Review comments
This commit is contained in:
@@ -12,12 +12,7 @@ inline const uint8_t bayer4x4[4][4] = {
|
|||||||
{15, 7, 13, 5},
|
{15, 7, 13, 5},
|
||||||
};
|
};
|
||||||
|
|
||||||
inline uint8_t quantizeGray4Level(uint8_t gray) {
|
inline uint8_t quantizeGray4Level(uint8_t gray) { return gray >= 213 ? 3 : static_cast<uint8_t>((gray + 42) / 85); }
|
||||||
if (gray < 64) return 0;
|
|
||||||
if (gray < 128) return 1;
|
|
||||||
if (gray < 192) return 2;
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply Bayer dithering and quantize to 4 levels (0-3)
|
// Apply Bayer dithering and quantize to 4 levels (0-3)
|
||||||
// Stateless - works correctly with any pixel processing order
|
// Stateless - works correctly with any pixel processing order
|
||||||
|
|||||||
@@ -92,7 +92,9 @@ BmpViewerActivity::BmpViewerActivity(GfxRenderer& renderer, MappedInputManager&
|
|||||||
filePath(std::move(path))
|
filePath(std::move(path))
|
||||||
#ifdef ENABLE_IMAGE_DITHERING_EXTENSION
|
#ifdef ENABLE_IMAGE_DITHERING_EXTENSION
|
||||||
,
|
,
|
||||||
imageDitherMode(normalizeImageDitherModeValue(SETTINGS.imageDithering)) {
|
imageDitherMode(normalizeImageDitherModeValue(SETTINGS.imageDithering)),
|
||||||
|
initialImageDitherMode(imageDitherMode),
|
||||||
|
imageDitherSettingsDirty(false) {
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
@@ -117,6 +119,9 @@ void BmpViewerActivity::onEnter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BmpViewerActivity::onExit() {
|
void BmpViewerActivity::onExit() {
|
||||||
|
#ifdef ENABLE_IMAGE_DITHERING_EXTENSION
|
||||||
|
saveDitherSettingsIfNeeded();
|
||||||
|
#endif
|
||||||
Activity::onExit();
|
Activity::onExit();
|
||||||
renderer.clearScreen();
|
renderer.clearScreen();
|
||||||
renderer.displayBuffer(HalDisplay::FULL_REFRESH);
|
renderer.displayBuffer(HalDisplay::FULL_REFRESH);
|
||||||
@@ -148,12 +153,7 @@ bool BmpViewerActivity::renderBmpImage(const bool showControls) {
|
|||||||
renderer.clearScreen();
|
renderer.clearScreen();
|
||||||
renderer.drawBitmap(bitmap, x, y, pageWidth, pageHeight, 0, 0);
|
renderer.drawBitmap(bitmap, x, y, pageWidth, pageHeight, 0, 0);
|
||||||
if (showControls) {
|
if (showControls) {
|
||||||
#ifdef ENABLE_IMAGE_DITHERING_EXTENSION
|
|
||||||
const auto labels =
|
|
||||||
mappedInput.mapLabels(tr(STR_BACK), "", I18N.get(getCurrentDitherModeLabel()), tr(STR_SET_SLEEP_SCREEN));
|
|
||||||
#else
|
|
||||||
const auto labels = mappedInput.mapLabels(tr(STR_BACK), "", "", tr(STR_SET_SLEEP_SCREEN));
|
const auto labels = mappedInput.mapLabels(tr(STR_BACK), "", "", tr(STR_SET_SLEEP_SCREEN));
|
||||||
#endif
|
|
||||||
GUI.drawButtonHints(renderer, labels.btn1, labels.btn2, labels.btn3, labels.btn4);
|
GUI.drawButtonHints(renderer, labels.btn1, labels.btn2, labels.btn3, labels.btn4);
|
||||||
}
|
}
|
||||||
renderer.displayBuffer(HalDisplay::HALF_REFRESH);
|
renderer.displayBuffer(HalDisplay::HALF_REFRESH);
|
||||||
@@ -232,12 +232,23 @@ StrId BmpViewerActivity::getCurrentDitherModeLabel() const {
|
|||||||
void BmpViewerActivity::cycleDitherMode() {
|
void BmpViewerActivity::cycleDitherMode() {
|
||||||
imageDitherMode = (imageDitherMode + 1) % CrossPointSettings::IMAGE_DITHERING_COUNT;
|
imageDitherMode = (imageDitherMode + 1) % CrossPointSettings::IMAGE_DITHERING_COUNT;
|
||||||
SETTINGS.imageDithering = imageDitherMode;
|
SETTINGS.imageDithering = imageDitherMode;
|
||||||
SETTINGS.saveToFile();
|
imageDitherSettingsDirty = (imageDitherMode != initialImageDitherMode);
|
||||||
|
|
||||||
if (!renderCurrentImage()) {
|
if (!renderCurrentImage()) {
|
||||||
renderError("Could not render image");
|
renderError("Could not render image");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BmpViewerActivity::saveDitherSettingsIfNeeded() {
|
||||||
|
if (!imageDitherSettingsDirty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SETTINGS.imageDithering = imageDitherMode;
|
||||||
|
SETTINGS.saveToFile();
|
||||||
|
initialImageDitherMode = imageDitherMode;
|
||||||
|
imageDitherSettingsDirty = false;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void BmpViewerActivity::renderError(const char* message) {
|
void BmpViewerActivity::renderError(const char* message) {
|
||||||
@@ -302,7 +313,7 @@ void BmpViewerActivity::loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_IMAGE_DITHERING_EXTENSION
|
#ifdef ENABLE_IMAGE_DITHERING_EXTENSION
|
||||||
if (mappedInput.wasReleased(MappedInputManager::Button::Left)) {
|
if (!isBmpFile(filePath) && mappedInput.wasReleased(MappedInputManager::Button::Left)) {
|
||||||
cycleDitherMode();
|
cycleDitherMode();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ class BmpViewerActivity final : public Activity {
|
|||||||
std::string filePath;
|
std::string filePath;
|
||||||
#ifdef ENABLE_IMAGE_DITHERING_EXTENSION
|
#ifdef ENABLE_IMAGE_DITHERING_EXTENSION
|
||||||
uint8_t imageDitherMode;
|
uint8_t imageDitherMode;
|
||||||
|
uint8_t initialImageDitherMode;
|
||||||
|
bool imageDitherSettingsDirty;
|
||||||
#endif
|
#endif
|
||||||
bool renderCurrentImage(bool showControls = true);
|
bool renderCurrentImage(bool showControls = true);
|
||||||
bool renderBmpImage(bool showControls = true);
|
bool renderBmpImage(bool showControls = true);
|
||||||
@@ -28,6 +30,7 @@ class BmpViewerActivity final : public Activity {
|
|||||||
#ifdef ENABLE_IMAGE_DITHERING_EXTENSION
|
#ifdef ENABLE_IMAGE_DITHERING_EXTENSION
|
||||||
void cycleDitherMode();
|
void cycleDitherMode();
|
||||||
StrId getCurrentDitherModeLabel() const;
|
StrId getCurrentDitherModeLabel() const;
|
||||||
|
void saveDitherSettingsIfNeeded();
|
||||||
#endif
|
#endif
|
||||||
void renderError(const char* message);
|
void renderError(const char* message);
|
||||||
void setAsSleepScreen();
|
void setAsSleepScreen();
|
||||||
|
|||||||
Reference in New Issue
Block a user