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

Different Bytes Count of QImage



  • Hi,
    Does anybody understand the size in bytes of the QImage?

    QImage image128(128, 128, QImage::Format_Grayscale8);
    image128.sizeInBytes(); // == 16384, which is 128*128  
    
    QImage image102(102, 102, QImage::Format_Grayscale8);
    image102.sizeInBytes(); // == 10608, which is NOT 102*102, but 102*104 ?!?
    

    Thanks



  • Hi,

    Because of 4 byte alignment (32 bit alignment):
    "The width and height must be specified in pixels, data must be 32-bit aligned, and each scanline of data in the image must also be 32-bit aligned"


Log in to reply