1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-16 11:19:18 +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:
David Sansome 2011-05-14 13:43:33 +00:00
parent c9a0318553
commit dfb0289987

View File

@ -37,7 +37,26 @@ QDBusArgument& operator<< (QDBusArgument& arg, const QImage& image) {
return arg;
}
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 << i.width();
arg << i.height();