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. Image transfer using QTcpsocket
Qt 6.11 is out! See what's new in the release blog

Image transfer using QTcpsocket

Scheduled Pinned Locked Moved General and Desktop
18 Posts 2 Posters 13.6k 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.
  • A Offline
    A Offline
    anmol2701
    wrote on last edited by
    #8

    image sending and saving is png format.
    Plz share
    Any documentation or link for more details??

    p3c0P 1 Reply Last reply
    0
    • A anmol2701

      image sending and saving is png format.
      Plz share
      Any documentation or link for more details??

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #9

      @anmol2701 I still doubt that some bytes are still missing on client side. How did you check that ?

      157

      1 Reply Last reply
      0
      • A Offline
        A Offline
        anmol2701
        wrote on last edited by anmol2701
        #10

        I was checking qDebug() << "Written : " << socket->write(ba);
        or qdeqint64 W_Length = file.readLine(buffer, sizeof(buffer));
        On client side qint64 R_bytes = buffer->write(socket->readAll());

        p3c0P 1 Reply Last reply
        0
        • A anmol2701

          I was checking qDebug() << "Written : " << socket->write(ba);
          or qdeqint64 W_Length = file.readLine(buffer, sizeof(buffer));
          On client side qint64 R_bytes = buffer->write(socket->readAll());

          p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #11

          @anmol2701 So are they equal ?
          On sender side you have the image i.e you can check its size in bytes manually and on the client side check the size of the whole bytearray from which you construct the image. They should match exactly.

          157

          A 1 Reply Last reply
          0
          • A Offline
            A Offline
            anmol2701
            wrote on last edited by
            #12
            This post is deleted!
            1 Reply Last reply
            0
            • p3c0P p3c0

              @anmol2701 So are they equal ?
              On sender side you have the image i.e you can check its size in bytes manually and on the client side check the size of the whole bytearray from which you construct the image. They should match exactly.

              A Offline
              A Offline
              anmol2701
              wrote on last edited by
              #13

              @p3c0 Hi!

              Now I am saving image using
              image_rcv.loadFromData(test);

              It gives error: libpng error: PNG unsigned integer out of range.
              Any Suggestion??

              p3c0P 1 Reply Last reply
              0
              • A anmol2701

                @p3c0 Hi!

                Now I am saving image using
                image_rcv.loadFromData(test);

                It gives error: libpng error: PNG unsigned integer out of range.
                Any Suggestion??

                p3c0P Offline
                p3c0P Offline
                p3c0
                Moderators
                wrote on last edited by
                #14

                @anmol2701 Are you now receiving all the data ? I see in your earlier post that you are sending 560 bytes and receiving 533 bytes on client side.

                157

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  anmol2701
                  wrote on last edited by
                  #15

                  Yes,

                  Now I am receiving all the data in case of png file.

                  p3c0P 1 Reply Last reply
                  0
                  • A anmol2701

                    Yes,

                    Now I am receiving all the data in case of png file.

                    p3c0P Offline
                    p3c0P Offline
                    p3c0
                    Moderators
                    wrote on last edited by
                    #16

                    @anmol2701 That error is from libpng. It is not able to reconstruct the image from the data. I guess the data is mismatched.

                    157

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      anmol2701
                      wrote on last edited by anmol2701
                      #17

                      Hi!

                      I am able construct image.
                      Now the problem is with large size of images.

                      I am following this approach:

                      while (buffer->canReadLine())
                      {
                      QByteArray data_r = buffer->readLine();
                      image_r.append(data_r);
                      }
                      Then create image from Qbytearray image_r.
                      Any suggestion?

                      p3c0P 1 Reply Last reply
                      0
                      • A anmol2701

                        Hi!

                        I am able construct image.
                        Now the problem is with large size of images.

                        I am following this approach:

                        while (buffer->canReadLine())
                        {
                        QByteArray data_r = buffer->readLine();
                        image_r.append(data_r);
                        }
                        Then create image from Qbytearray image_r.
                        Any suggestion?

                        p3c0P Offline
                        p3c0P Offline
                        p3c0
                        Moderators
                        wrote on last edited by
                        #18

                        @anmol2701 If your earlier logic works perfectly then it should work for all files.
                        Anyway you can also look at serialization. Qt has provision to serialize some of the Qt data types. QDataStream can be used here to transferQImage directly. Have a look at fortuneserver and fortuneclient example. Try doing similar for QImage.

                        157

                        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