QPixmap and 16-bit colour depth

  • Hi,

    I'm developing for Windows CE 5.0 and for a display that only has 16-bit colour depth. Is there a performance hit for having all the QPixmaps at 32-bit colour depth, if so is there a way to solve this? It seems that even if I load 16-bit bitmaps they get converted internally to 32-bit. I'm just concerned that the processor is doing lots of 32 -> 16 conversions every paint.



  • It seems that even if I load 16-bit bitmaps they get converted internally to 32-bit

    Can you elaborate why you think so?

  • Also, check if QImageReader can be of any help in your case

  • Ahem, sorry my mis-reading of the QPixmap help on defaultDepth. I thought the "is always 32 on Windows" covered WinCE too. Having run a test on the platform the defaultDepth comes back as 16 so I don't think I need to worry.

    I'll get my coat...

  • u could also try with QImageReader, I've found it better in terms of memory footprint and performance

  • Yes, blitting a 32bit pixmap to 16bit screen, or the other way 16bit to 32bit, will typically give a significant performance hit. For every blit the system needs to rearrange the colors you are blitting into the right format. This is bad.

    Even 32bit to 32bit or 16bit to 16bit can give a performance hit if the bit-order, the format of RGB, is different. For example it could be a 565 being blitted to a 556 or whatver funky stuff you have :) Check out "http://doc.qt.nokia.com/4.6/qimage.html#Format-enum":http://doc.qt.nokia.com/4.6/qimage.html#Format-enum to see a list of the different formats we're talking about here.

    Typically Qt will detect what the proper depth and format is for your system, and automatically choose that for the pixmaps in Qt, but it could be an idea for you to really check that what you're blitting (number of bits and also the format) is the same as what the screen is running on.

    "Depending on the system, QPixmap is stored using a RGB32 or a premultiplied alpha format. If the image has an alpha channel, and if the system allows, the preferred format is premultiplied alpha."
    from "http://doc.qt.nokia.com/4.6/qpixmap.html#pixmap-information

    However, you QImages are probably still 32bit I would assume. Unless you need an alpha channel when you paint on them , you might consider using QImages of QImage::Format_RGB16 instead. It's not like you need 32bit color depth if you end up blitting it all to a 16bit display. Saves a lot of memory and should be faster as well.

    [edit: fixed links / $chetankjain]

  • hi snowpong, changed the urls you posted to links

  • Thanks. I assumed they'd be "auto" generated - I know better now :)

Log in to reply