Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QImage format for floating point image data



  • My application currently holds the image data that it is processing in a number of templated "bitmap" classes (not related to Windows DIB).

    Specifically they are:

    Colour bitmaps:

    24 bit colour (3 planes RGB 8 bit)
    48 bit colour (3 planes RGB 16 bit)
    96 bit colour (3 planes RGB 32 bit)
    96 bit colour float (32 planes RGB 32 bit float)

    Monochrome bitmaps (one plane only)

    Single bit bitmap
    8 bit bitmap
    16 bit bitmap
    32 bit bitmap
    32 bit float bitmap

    My problem is that I can create a QImage whose pixel values are correct for the integer representations (by converting to an in storage DIB), but there doesn't appear to be any QImage variant that supports floating point image data.

    The above approach also may not work on MacOS and Linux (do they have DIB support like Windows?).

    Is this a problem I'm just going to have to "hack" my way around (e.g. scale the float bitmap pixel values to uint values and retain a pointer to the original data when I need the raw pixel value), or is there a better solution?

    Thanks a lot
    David



  • Irrelevant of "modern video hardware", traditional video memory is most often planar, where each primary color gun gets a contiguous chunk of memory, and mapping of integral RGB values into that memory is far more efficient than doing floating point translations for each pixel. My sensibilities tell me that directly supporting floating point QImage would be grossly innefficient, and the docs ony reference formats of fixed bit widths for each color plane.



  • What's this got to do with video? These are still images that I need to handle as float. You don't normally render a QImage to the computer display - you would normally interpose a Pixmap which can be 8bits or 16bits per plane.



  • @Perdrix said in QImage format for floating point image data:

    (e.g. scale the float bitmap pixel values to uint values and retain a pointer to the original data when I need the raw pixel value)

    So far as I know, that is what you will need to do. As you can see, QImage/QPixmap only deals with integer values.



  • @Perdrix said in QImage format for floating point image data:

    What's this got to do with video? These are still images that I need to handle as float. You don't normally render a QImage to the computer display - you would normally interpose a Pixmap which can be 8bits or 16bits per plane.

    It's still purely a matter of efficiency. If you need floating point color data then you should create a specialization of QImage where the constructor converts and stores floating point data in the recognized integer format, and if you want to export that data back out as floating point then it translates it back to export, with the understanding that you may lose fidelity. Any internal pixel operations on floating point are going to be innefficient and complex, and thus the reason it's not directly supported.


Log in to reply