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. [SOLVED] QImage using pointer to valarray ?
QtWS25 Last Chance

[SOLVED] QImage using pointer to valarray ?

Scheduled Pinned Locked Moved General and Desktop
qimagevalarraypointer
6 Posts 2 Posters 2.3k 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.
  • C Offline
    C Offline
    CamelFrog
    wrote on 26 May 2015, 16:44 last edited by CamelFrog
    #1

    Hello,

    I'm new to this Forum. In the context of loading and visualising scientific images in FITS files, as quick as possible, I am using valarray, used by the CCFITSIO library. The latter reads raw scientific images in these objects. From the QImage doc, and this specific overload :

    • QImage(uchar * data, int width, int height, Format format)

    I understand that QImage could take a pointer to some data in a buffer.

    Is there any way to get a pointer to, say, valarray<float> myValArray ? And give it to QImage, without making any intermediate copies ?

    At the moment, the compiler (VS2013) does not allow me to use
    &myValArray[0] in QImage. I assume this comes from my misunderstanding of either QImage and valArray objects.

    Thanks for your help.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 26 May 2015, 21:10 last edited by
      #2

      Hi and welcome to devnet,

      QImage doesn't support float AFAIK. You should rather write a QImageReader subclass that decodes your image data in something supported by QImage

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

      C 1 Reply Last reply 27 May 2015, 08:18
      1
      • S SGaist
        26 May 2015, 21:10

        Hi and welcome to devnet,

        QImage doesn't support float AFAIK. You should rather write a QImageReader subclass that decodes your image data in something supported by QImage

        C Offline
        C Offline
        CamelFrog
        wrote on 27 May 2015, 08:18 last edited by
        #3

        @SGaist
        Thank you for your reply.

        Then, what should be the type of the array whose pointer can be sent to QImage(uchar *data,...) ?

        Thanks

        C 1 Reply Last reply 28 May 2015, 10:04
        0
        • C CamelFrog
          27 May 2015, 08:18

          @SGaist
          Thank you for your reply.

          Then, what should be the type of the array whose pointer can be sent to QImage(uchar *data,...) ?

          Thanks

          C Offline
          C Offline
          CamelFrog
          wrote on 28 May 2015, 10:04 last edited by
          #4

          Does QImage(uchar* data) means necessarily that i can only send char array, with numbers spanning from 0 to 255 ?

          Are there other Qt classes that support other types of image arrays that are to be displayed ?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 28 May 2015, 21:52 last edited by
            #5

            It can be something else as long as there's a reader that can translate it in a format QImage understands.

            QImage is the base image class, what can be done is to use OpenCV to convert your image data into something QImage can handle

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

            C 1 Reply Last reply 29 May 2015, 16:42
            0
            • S SGaist
              28 May 2015, 21:52

              It can be something else as long as there's a reader that can translate it in a format QImage understands.

              QImage is the base image class, what can be done is to use OpenCV to convert your image data into something QImage can handle

              C Offline
              C Offline
              CamelFrog
              wrote on 29 May 2015, 16:42 last edited by
              #6

              @SGaist
              Ok, I just tried to rescaled my image array within an intensity between 0 to 255 and cast a uchar*, it's working now.

              Thanks

              1 Reply Last reply
              0

              6/6

              29 May 2015, 16:42

              • Login

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