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. QImage buffer structure
Forum Updated to NodeBB v4.3 + New Features

QImage buffer structure

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 526 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.
  • fcarneyF Offline
    fcarneyF Offline
    fcarney
    wrote on last edited by
    #1

    Does QImage store its data in a contiguous buffer? I know you can get a scanline pointer and a bits pointer. It says that those point to a single scanline at least. Can this pointer be used to access the entire image?

    I guess the alternative would to make a holder class that feeds it a buffer that is contiguous and access that buffer of data.

    I have a library that resizes images and it requires access to a buffer that is contiguous. So either I have to copy the data out line by line into a working buffer or provide a buffer to the QImage object in the first place.

    C++ is a perfectly valid school of magic.

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by fcarney
      #2

      I should have just looked at the source code first.
      Yes, it is a continuous segment of memory. The scanline and bits functions return a pointer to this data that is stored as uchar*. The scanline functions actually return a calculated pointer into this data. So I could safely use the const version of these to prevent a detach and process the image data.

      So to access this I should just be using "const uchar *QImage::bits() const" for read only access.

      C++ is a perfectly valid school of magic.

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

        @fcarney said in QImage buffer structure:

        Can this pointer be used to access the entire image?

        Yes, for sure - otherwise it would be a very poor implementation and suboptimal implementation. Also the ctors show you that it's a contiguous buffer since some of them take exactly such a buffer without copying the buffer.

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

        fcarneyF 1 Reply Last reply
        4
        • Christian EhrlicherC Christian Ehrlicher

          @fcarney said in QImage buffer structure:

          Can this pointer be used to access the entire image?

          Yes, for sure - otherwise it would be a very poor implementation and suboptimal implementation. Also the ctors show you that it's a contiguous buffer since some of them take exactly such a buffer without copying the buffer.

          fcarneyF Offline
          fcarneyF Offline
          fcarney
          wrote on last edited by
          #4

          @Christian-Ehrlicher said in QImage buffer structure:

          ctors show you that it's a contiguous buffer since some of them take exactly such a buffer without copying the buffer

          Yes, but I didn't know if the internal implementation was different in that case. I really needed to look at the code and make sure. The documentation didn't lead me to believe this for certain. It is a good point though. Which is part of the reason I wondered.

          C++ is a perfectly valid school of magic.

          1 Reply Last reply
          1

          • Login

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