QPainter Color Shift (red/blue swapped) on mobile devices



  • I'm drawing an png image using Qt 5.6 (commercial), Qt Creator (for the mobile program), Visual Studio 2013 (for the windows program): basically I'm using QPainter and QImage for rendering
    Here are some lines of my code:
    QImage img(w, h, QImage::Format_ARGB32_Premultiplied);
    img.fill(Qt::transparent);
    QPainter qpainter(img);
    qpainter.setRenderHint(QPainter::Antialiasing, true);

    This works fine for rendering an image on Windows. When rendering the image on a mobile devices (in my case a Samsung Galaxy Tablet) the colors are shiftet. To be precise red and blue are swaped. I copied this image from the tablet to windows and the image has still shifted colors. Thus it seems to be a problem in the rendering process.

    Using an image with alpha channel is important. I can't switch to a format whithout alpha.
    I tried some other alpha channel formats, e.g. Format_ARGB32. But the color problem still occurs.

    I changed the program such that it swaps red/blue and the picture rendered on the tablet looks fine (of course now rendering on windows results in wrong colors). But this is not a good solution, since I dont now if this behavior is on every tablet the same.

    Is there something known about this color shifts on mobile devices? Do you have any suggestions?

    Thanks a lot,

    Jörg



  • The colour formats should work just fine on Android. One possibility with is always a bug in some seemingly unrelated function, so I would remove and change parameters on every function used, starting with setRenderHint.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Which version of Android are you using ?



  • We use a Samsung SMT710 with Android Version 5.0.2 Patch 20151101


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.