Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Supporting 16 bit images with Qt

Supporting 16 bit images with Qt

Scheduled Pinned Locked Moved Solved Mobile and Embedded
9 Posts 3 Posters 3.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SachinBhatS Offline
    SachinBhatS Offline
    SachinBhat
    wrote on last edited by
    #1

    Hi,

    We have developed a GUI application for loading images to our embedded platform. We need to load 16 bit images from tiff file format. The application uses 32 bit version of Qt 5.12 currently. I am able to load the tiff image in format 25. But this stores pixels in the form of 64 bit word which I cannot access as our application is 32 bit.

    I got to know that qt supports 16 bit grayscale images which is okay for us as format 28 is supported in version 5.13. I can port our application to latest one.

    I need clarification regarding format 28. Will it automatically convert a 48 bit rgb image to 16 bit? if yes, could you please suggest a way to do it?

    Thanks
    Sachin

    1 Reply Last reply
    0
    • SachinBhatS SachinBhat

      This gives me error

      int WaveFormWindow::quantize(QImage const &src, int bitDepth, QImage *dst)
      {
      uint08 mask;
      uint08 orMask;
      uint08 shift;

      uint16 mask1, orMask1;
      int minHeight = MIN(dst->height(),src.height());
      int minWidth = MIN(dst->width(),src.width());
      QImage image = src;
      
      uint16 *p = reinterpret_cast<uint16*>(image.scanLine());
      

      }

      error: const_cast from 'const uchar *' (aka 'const unsigned char *') to 'uint16 *' (aka 'unsigned short *') is not allowed

      I am not able to cast uint08 ptr to uint16 ptr. Please help

      Thanks
      in advance

      Regards
      Sachin

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #8

      @SachinBhat said in Supporting 16 bit images with Qt:

      uint16 p = reinterpret_cast<uint16>(image.scanLine());

      const uint16 *p = reinterpret_cast<const uint16*>(image.scanLine());
      

      should do...

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • SachinBhatS Offline
        SachinBhatS Offline
        SachinBhat
        wrote on last edited by
        #2

        Also, If there is any way I can get the R G and B components of the 16 bit image in 32 bit version of application, then it would make it much easier for me

        Thanks
        Sachin

        M 1 Reply Last reply
        0
        • SachinBhatS Offline
          SachinBhatS Offline
          SachinBhat
          wrote on last edited by
          #3

          QImage::Format_Grayscale16 28 The image is stored using an 16-bit grayscale format. (added in Qt 5.13)
          QImage::Format_RGBX64 25 The image is stored using a 64-bit halfword-ordered RGB(x) format (16-16-16-16). This is the same as the Format_RGBA64 except alpha must always be 65535. (added in Qt 5.12)
          QImage::Format_RGBA64 26 The image is stored using a 64-bit halfword-ordered RGBA format (16-16-16-16). (added in Qt 5.12)
          QImage::Format_RGBA64_Premultiplied 27 The image is stored using a premultiplied 64-bit halfword-ordered RGBA format (16-16-16-16). (added in Qt 5.12)

          The formats currently supported in Qt for 16 bit

          Thanks
          Sachin

          1 Reply Last reply
          0
          • SachinBhatS SachinBhat

            Also, If there is any way I can get the R G and B components of the 16 bit image in 32 bit version of application, then it would make it much easier for me

            Thanks
            Sachin

            M Offline
            M Offline
            mvuori
            wrote on last edited by
            #4

            Nobody is supposed to know what formats 25 and 28 are.... Qt has symbol to represent formats.

            But QImage has bits() and you can read them anyway you like - just get larger chunks for each pixel and its component.

            1 Reply Last reply
            0
            • SachinBhatS Offline
              SachinBhatS Offline
              SachinBhat
              wrote on last edited by SachinBhat
              #5

              I use scanLine() to get the pointer of the particular line. But i get a uint08 * pointer. However it would be easy to get a uint16* pointer for processing. Any way to achieve this?

              jsulmJ 1 Reply Last reply
              0
              • SachinBhatS SachinBhat

                I use scanLine() to get the pointer of the particular line. But i get a uint08 * pointer. However it would be easy to get a uint16* pointer for processing. Any way to achieve this?

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #6

                @SachinBhat said in Supporting 16 bit images with Qt:

                Any way to achieve this?

                A simple cast of the pointer:

                uint16 *p = reinterpret_cast<uint16*>(image.scanLine());
                

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                2
                • SachinBhatS Offline
                  SachinBhatS Offline
                  SachinBhat
                  wrote on last edited by SachinBhat
                  #7

                  This gives me error

                  int WaveFormWindow::quantize(QImage const &src, int bitDepth, QImage *dst)
                  {
                  uint08 mask;
                  uint08 orMask;
                  uint08 shift;

                  uint16 mask1, orMask1;
                  int minHeight = MIN(dst->height(),src.height());
                  int minWidth = MIN(dst->width(),src.width());
                  QImage image = src;
                  
                  uint16 *p = reinterpret_cast<uint16*>(image.scanLine());
                  

                  }

                  error: const_cast from 'const uchar *' (aka 'const unsigned char *') to 'uint16 *' (aka 'unsigned short *') is not allowed

                  I am not able to cast uint08 ptr to uint16 ptr. Please help

                  Thanks
                  in advance

                  Regards
                  Sachin

                  jsulmJ 1 Reply Last reply
                  0
                  • SachinBhatS SachinBhat

                    This gives me error

                    int WaveFormWindow::quantize(QImage const &src, int bitDepth, QImage *dst)
                    {
                    uint08 mask;
                    uint08 orMask;
                    uint08 shift;

                    uint16 mask1, orMask1;
                    int minHeight = MIN(dst->height(),src.height());
                    int minWidth = MIN(dst->width(),src.width());
                    QImage image = src;
                    
                    uint16 *p = reinterpret_cast<uint16*>(image.scanLine());
                    

                    }

                    error: const_cast from 'const uchar *' (aka 'const unsigned char *') to 'uint16 *' (aka 'unsigned short *') is not allowed

                    I am not able to cast uint08 ptr to uint16 ptr. Please help

                    Thanks
                    in advance

                    Regards
                    Sachin

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by jsulm
                    #8

                    @SachinBhat said in Supporting 16 bit images with Qt:

                    uint16 p = reinterpret_cast<uint16>(image.scanLine());

                    const uint16 *p = reinterpret_cast<const uint16*>(image.scanLine());
                    

                    should do...

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    2
                    • SachinBhatS Offline
                      SachinBhatS Offline
                      SachinBhat
                      wrote on last edited by
                      #9

                      Thank you very much for your support

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved