Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Change algorithm for determining number of generated frames

Luna Lovecraft794cc08d83c0
diff --git a/plugins/dockers/recorder/recorder_writer.cpp b/plugins/dockers/recorder/recorder_writer.cpp
index 6a08b24bc1..bf6a22a12e 100644
--- a/plugins/dockers/recorder/recorder_writer.cpp
+++ b/plugins/dockers/recorder/recorder_writer.cpp
@@ -699,13 +699,14 @@ void RecorderWriterManager::onTimer()
int totalFrames = 1;
// Change in the region, let's generate some frames
if (interpolate) {
- float diffX = abs(region.x() - d->oldRegion.x()) / (float)fullSize.width();
- float diffY = abs(region.y() - d->oldRegion.y()) / (float)fullSize.height();
- float diffW = abs(region.width() - d->oldRegion.width()) / (float)fullSize.width();
- float diffH = abs(region.height() - d->oldRegion.height()) / (float)fullSize.height();
+ // Prevent a divide by zero..
+ float diffX = abs(region.x() - d->oldRegion.x()) / std::max(1.0f, (float)d->oldRegion.width());
+ float diffY = abs(region.y() - d->oldRegion.y()) / std::max(1.0f, (float)d->oldRegion.height());
+ float diffW = abs(region.width() - d->oldRegion.width()) / std::max(1.0f, (float)d->oldRegion.width());
+ float diffH = abs(region.height() - d->oldRegion.height()) / std::max(1.0f, (float)d->oldRegion.height());
// Find the highest diff
- float maxDiff = std::max({diffX, diffY, diffW, diffH});
+ float maxDiff = std::min(std::max({diffX, diffY, diffW, diffH}), 1.0f);
// Maximum amount of interpolation frames to generate
const int maxFrames = 10;