mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-17 03:45:56 +01:00
Fix the byte order of album cover art images sent over dbus on big endian machines. Thanks Paul Wells
This commit is contained in:
parent
c9a0318553
commit
dfb0289987
@ -37,7 +37,26 @@ QDBusArgument& operator<< (QDBusArgument& arg, const QImage& image) {
|
|||||||
return arg;
|
return arg;
|
||||||
}
|
}
|
||||||
QImage scaled = image.scaledToHeight(100, Qt::SmoothTransformation);
|
QImage scaled = image.scaledToHeight(100, Qt::SmoothTransformation);
|
||||||
QImage i = scaled.convertToFormat(QImage::Format_ARGB32).rgbSwapped();
|
|
||||||
|
scaled = scaled.convertToFormat(QImage::Format_ARGB32);
|
||||||
|
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
|
||||||
|
// ABGR -> ARGB
|
||||||
|
QImage i = scaled.rgbSwapped();
|
||||||
|
#else
|
||||||
|
// ABGR -> GBAR
|
||||||
|
QImage i(scaled.size(), scaled.format());
|
||||||
|
for (int y = 0; y < i.height(); ++y) {
|
||||||
|
QRgb* p = (QRgb*) scaled.scanLine(y);
|
||||||
|
QRgb* q = (QRgb*) i.scanLine(y);
|
||||||
|
QRgb* end = p + scaled.width();
|
||||||
|
while (p < end) {
|
||||||
|
*q = qRgba(qGreen(*p), qBlue(*p), qAlpha(*p), qRed(*p));
|
||||||
|
p++;
|
||||||
|
q++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
arg.beginStructure();
|
arg.beginStructure();
|
||||||
arg << i.width();
|
arg << i.width();
|
||||||
arg << i.height();
|
arg << i.height();
|
||||||
|
Loading…
Reference in New Issue
Block a user