Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Pointer to QByteArray as LPBYTE
Forum Updated to NodeBB v4.3 + New Features

Pointer to QByteArray as LPBYTE

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 1.0k Views 2 Watching
  • 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.
  • R Offline
    R Offline
    Rory_1
    wrote on last edited by Rory_1
    #1

    I am attempting to provide color management for my Qt image viewing app using the library lcms2. I have everything working except pulling the icc profile from a jpeg file. I have extracted the icc segment in a QByteArray called iccBuf.

    lcms2 has a function:
    cmsOpenProfileFromMem(const void * MemPtr, cmsUInt32Number dwSize);

    "Opens an ICC profile which is entirely contained in a memory block. Useful for accessing embedded profiles. MemPtr must point to a buffer of at least dwSize bytes. This buffer must hold a full profile image. Memory must be contiguous."

    I have seen code that supplies the MemPtr parameter as a LPBYTE but I cannot convert the QByteArray address to LPBYTE. I have tried:

    reinterpret_cast<const void*>(&(iccBuf).data()[0])
    and
    (unsigned char*)G::iccBuf.data()

    but these do not work.

    It appears I need to convert char* to uchar*

    Any advice would be greatly permitted.

    Thanks in advance!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What exact error are you getting ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      R 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        What exact error are you getting ?

        R Offline
        R Offline
        Rory_1
        wrote on last edited by Rory_1
        #3

        @sgaist The function cmsOpenProfileFromMem is returning a nullptr indicating failure.

        Snippet:

        QByteArray iccBuf;
        // load iccBuf with file icc data segment
        quint32 iccLen = iccBuf.length();  
        LPBYTE buf = (unsigned char*)iccBuf.data();
        hInProfile = cmsOpenProfileFromMem(iccData, iccLen);
        // output from qDebug:
        iccBuf.data() = 0x7ff61053e5c0    buf = 0x1a2811400c8
        
        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          I've no documentation for cmsOpenProfileFromMem() but how should it suppose to work when you pass a pointer to data with a length of zero?

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          R 1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            I've no documentation for cmsOpenProfileFromMem() but how should it suppose to work when you pass a pointer to data with a length of zero?

            R Offline
            R Offline
            Rory_1
            wrote on last edited by
            #5

            @christian-ehrlicher Apologies - I quickly threw together the use case. The variable iccLen is defined in the code as the length of iccBuf. I have tweaked the code above to show this.

            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @rory_1 said in Pointer to QByteArray as LPBYTE:

              The variable iccLen is defined in the code as the length of iccBuf.

              ... which is still zero since you have an empty QByteArray

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              R 1 Reply Last reply
              1
              • Christian EhrlicherC Christian Ehrlicher

                @rory_1 said in Pointer to QByteArray as LPBYTE:

                The variable iccLen is defined in the code as the length of iccBuf.

                ... which is still zero since you have an empty QByteArray

                R Offline
                R Offline
                Rory_1
                wrote on last edited by
                #7

                @christian-ehrlicher Yes I know. I was trying to state in my comments that I obtained the byte array and was continuing. I agree that was not clear. I have solved the issue - my test jpg file had a non-compliant embedded profile.

                Many thanks for taking the time to help!

                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