diff --git a/kimgio/ico.cpp b/kimgio/ico.cpp index 404d64d8..9c9790f6 100644 --- a/kimgio/ico.cpp +++ b/kimgio/ico.cpp @@ -240,8 +240,16 @@ bool ICOHandler::read(QImage *image) switch (bmpbpp) { case 32: { +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + QRgb* bmpimagebits = reinterpret_cast(bmpimage.bits()); + for (uint bi = 0; bi < bmpimagesize && bi < imageboundary; bi += 4) { + *bmpimagebits = qRgba(imagebytes.at(bi + 2), imagebytes.at(bi + 1), imagebytes.at(bi), imagebytes.at(bi + 3)); + bmpimagebits++; + } +#else char* bmpimagebits = reinterpret_cast(bmpimage.bits()); ::memcpy(bmpimagebits, imagebytes.constData(), imageboundary * sizeof(char)); +#endif break; } case 24: { @@ -340,8 +348,20 @@ bool ICOHandler::write(const QImage &image) datastream << bmpncolors; datastream << bmpnimportantcolors; +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + const QRgb* bmpimagebits = reinterpret_cast(bmpimage.constBits()); + for (uint bi = 0; bi < bmpimagesize; bi += 4) { + const uchar bmpb = qBlue(*bmpimagebits); + const uchar bmpg = qGreen(*bmpimagebits); + const uchar bmpr = qRed(*bmpimagebits); + const uchar bmpa = qAlpha(*bmpimagebits); + datastream << bmpb << bmpg << bmpr << bmpa; + bmpimagebits++; + } +#else const char* bmpimagebits = reinterpret_cast(bmpimage.constBits()); datastream.writeRawData(bmpimagebits, bmpimagesize); +#endif return (datastream.status() == QDataStream::Ok); } diff --git a/kimgio/webp.cpp b/kimgio/webp.cpp index 805cdbc4..0a688e00 100644 --- a/kimgio/webp.cpp +++ b/kimgio/webp.cpp @@ -138,6 +138,7 @@ bool WebPHandler::write(const QImage &image) uint8_t *webpoutput = nullptr; #if Q_BYTE_ORDER == Q_BIG_ENDIAN + // TODO: move alpha? const size_t webpsize = WebPEncodeRGBA( #else const size_t webpsize = WebPEncodeBGRA( @@ -323,6 +324,4 @@ QImageIOHandler *WebPPlugin::create(QIODevice *device, const QByteArray &format) return handler; } -//--------------------------------------------------------------------- - Q_EXPORT_PLUGIN2(webp, WebPPlugin)