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. Is there a way to get the raw bits of a QImage without a deep copy?
Qt 6.11 is out! See what's new in the release blog

Is there a way to get the raw bits of a QImage without a deep copy?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 2.4k Views 1 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.
  • N Offline
    N Offline
    ntsirak1
    wrote on last edited by
    #1

    I'm looking to efficiently get the raw data behind a non-constant QImage, but QImage::bits() seems to always perform a deep copy. Is there a way to just get a pointer to the data?

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

      Hi
      http://doc.qt.io/qt-5/qimage.html#constScanLine
      "this function does not perform a deep copy of the shared pixel data"

      1 Reply Last reply
      3
      • N Offline
        N Offline
        ntsirak1
        wrote on last edited by ntsirak1
        #3

        Thanks for your response. I was under the impression that this only applies to images that have constant data. If the image changes will this return value update as well?

        mrjjM 1 Reply Last reply
        0
        • G Offline
          G Offline
          Gerd
          wrote on last edited by
          #4

          There is also a function constBits()...

          1 Reply Last reply
          0
          • N ntsirak1

            Thanks for your response. I was under the impression that this only applies to images that have constant data. If the image changes will this return value update as well?

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @ntsirak1
            Hi
            The const part means you cannot modify the returned data (bits) and is meant for fast reading.
            If you need to alter the image, the const functions are a no go.

            1 Reply Last reply
            4
            • N Offline
              N Offline
              ntsirak1
              wrote on last edited by
              #6

              @mrjj Awesome, thanks a lot for clarifying. Marking as solved.

              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