Fix moodbar

This commit is contained in:
Jonas Kvinge 2021-03-23 01:44:00 +01:00
parent ffc5446914
commit 9cde537066
2 changed files with 7 additions and 6 deletions

View File

@ -175,7 +175,7 @@ QByteArray MoodbarBuilder::Finish(int width) {
for (int i = 0; i < width; ++i) {
Rgb rgb;
const int start = i * static_cast<int>(frames_.count()) / width;
const int start = static_cast<int>(i * frames_.count() / width);
const int end = std::max((i + 1) * static_cast<int>(frames_.count()) / width, start + 1);
for (int j = start; j < end; j++) {
@ -187,9 +187,10 @@ QByteArray MoodbarBuilder::Finish(int width) {
const int n = end - start;
*(data++) = char(rgb.r / n);
*(data++) = char(rgb.g / n);
*(data++) = char(rgb.b / n);
*(data++) = rgb.r / n;
*(data++) = rgb.g / n;
*(data++) = rgb.b / n;
}
return ret;

View File

@ -119,8 +119,8 @@ void MoodbarRenderer::Render(const ColorVector &colors, QPainter *p, const QRect
int g = 0;
int b = 0;
int start = x * static_cast<int>(colors.size() / rect.width());
int end = (x + 1) * static_cast<int>(colors.size() / rect.width());
int start = static_cast<int>(x * colors.size() / rect.width());
int end = static_cast<int>((x + 1) * colors.size() / rect.width());
if (start == end) end = qMin(start + 1, colors.size() - 1);