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. Passing QImage data from a text file or data stream
QtWS25 Last Chance

Passing QImage data from a text file or data stream

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 1.4k 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.
  • J Offline
    J Offline
    jamie
    wrote on last edited by
    #1

    I am building some functions to handle data from multiple imaging devices, I have written functions to collected data and it returns the data in the format:

    x-coord y-coord value
    0 0 2001
    0 1 1999
    ...

    I can parse this data in C++ and would like to build a GUI to visualise this image. As I understand, I should use QImage. From the documentation it looks as if I need to use QImage::load() or QImage::loadFromData(), but they read binary data and my data is not in that form.

    Would anyone be able to point me in the right direction? Thanks!

    raven-worxR 1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      No, QImage is not smart enough to detect your custom format (here you can find a list of supported formats). just create a QImage with the resulting size and then iterate x and y and call setPixel(x,y,value) to build it

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      J.HilkJ 1 Reply Last reply
      4
      • VRoninV VRonin

        No, QImage is not smart enough to detect your custom format (here you can find a list of supported formats). just create a QImage with the resulting size and then iterate x and y and call setPixel(x,y,value) to build it

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @VRonin said in Passing QImage data from a text file or data stream:

        No, QImage is not smart enough to detect your custom format (here you can find a list of supported formats). just create a QImage with the resulting size and then iterate x and y and call setPixel(x,y,value) to build it

        Even so it's probably the right way to do it, this sounds like it would take, figuratively, forever to create the QImage that way.


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        0
        • J jamie

          I am building some functions to handle data from multiple imaging devices, I have written functions to collected data and it returns the data in the format:

          x-coord y-coord value
          0 0 2001
          0 1 1999
          ...

          I can parse this data in C++ and would like to build a GUI to visualise this image. As I understand, I should use QImage. From the documentation it looks as if I need to use QImage::load() or QImage::loadFromData(), but they read binary data and my data is not in that form.

          Would anyone be able to point me in the right direction? Thanks!

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by raven-worx
          #4

          @jamie
          the most reusable way would probably be to create a custom imageformat plugin by implementing QImageIOPlugin interface (in a custom Qt plugin).
          Take this a reference for example.

          In the plugin you still need to create a QImage at some point (in QImageIOHandler::read(), to be specific). But i wouldn't use QImage::setPixel() for that but write the (qRgb-)data directly into memory by using QImage::bits() then.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          5

          • Login

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