Skip to content
This repository was archived by the owner on Jan 28, 2022. It is now read-only.

Commit 7502ab2

Browse files
committed
refactor: use dominant color method for album art color
Closes #421
1 parent 2e72ffa commit 7502ab2

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

components/media_player/sources/utils_mediaplayer.cpp

+6-11
Original file line numberDiff line numberDiff line change
@@ -172,21 +172,16 @@ void MediaPlayerUtilsWorker::generateImagesReply() {
172172
/// GET DOMINANT COLOR
173173
////////////////////////////////////////////////////////////////////
174174
qCDebug(CLASS_LC()) << this << "Getting dominant color";
175-
// QColor m_pixelColor = dominantColor(image);
176-
177-
// shrink down image to 1x1 pixel and measure the color
178-
QImage onePixel = image;
179-
onePixel.scaled(1, 1, Qt::IgnoreAspectRatio);
180-
QColor m_pixelColor = onePixel.pixel(1, 1);
175+
QColor pixelColor = dominantColor(image);
181176

182177
// change the brightness of the color if it's too bright
183-
if (m_pixelColor.lightness() > 150) {
184-
m_pixelColor.setHsv(m_pixelColor.hue(), m_pixelColor.saturation(), (m_pixelColor.value() - 80));
178+
if (pixelColor.lightness() > 150) {
179+
pixelColor.setHsv(pixelColor.hue(), pixelColor.saturation(), (pixelColor.value() - 80));
185180
}
186181

187182
// if the color is close to white, return black instead
188-
if (m_pixelColor.lightness() > 210) {
189-
m_pixelColor = QColor("black");
183+
if (pixelColor.lightness() > 210) {
184+
pixelColor = QColor("black");
190185
}
191186

192187
////////////////////////////////////////////////////////////////////
@@ -208,7 +203,7 @@ void MediaPlayerUtilsWorker::generateImagesReply() {
208203

209204
qCDebug(CLASS_LC()) << this << "Creating image DONE";
210205

211-
emit processingDone(m_pixelColor, image);
206+
emit processingDone(pixelColor, image);
212207
}
213208
} else {
214209
qCWarning(CLASS_LC) << this << "NETWORK REPLY ERROR" << m_reply->errorString();

0 commit comments

Comments
 (0)