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. RGB Image Array produces an Array with random newlines here and there, why?
Forum Updated to NodeBB v4.3 + New Features

RGB Image Array produces an Array with random newlines here and there, why?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 418 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.
  • K Offline
    K Offline
    Kris Revi
    wrote on last edited by
    #1

    This

    void MainWindow::selectedImageDisplay(QString img)
    {
        QImage imageObject;    // Make a new imageObject
        imageObject.load(img); // Load the image from path
    
        imageObject = imageObject.convertToFormat(QImage::Format_RGB16);
    
        QJsonArray RGB565;
        for(int y = 0; y < 128; y++)
        {
            const quint16 *line = reinterpret_cast<const quint16*>(imageObject.constScanLine(y));
            for(int x = 0; x < 128; x++)
            {
                RGB565 << *(line++);
            }
        }
    
        socket.sendCommandStrip("pixArt", RGB565);
    }
    

    produces this (with random newlines here and there) why? :/
    https://pastebin.com/raw/GXWWjgRr

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      What is the text output of RGB565 before sending to a socket? Are you seeing the line breaks on the receiving side of the socket or are the newlines embedded in the QJsonArray?

      What are the capabilities of the RGB565 object? Is there a max line length that object type can handle?

      not enough information is given about socket and sendCommandStrip() to know if the problem is in the socket comms or in the RGB565 object.

      K 1 Reply Last reply
      1
      • Kent-DorfmanK Kent-Dorfman

        What is the text output of RGB565 before sending to a socket? Are you seeing the line breaks on the receiving side of the socket or are the newlines embedded in the QJsonArray?

        What are the capabilities of the RGB565 object? Is there a max line length that object type can handle?

        not enough information is given about socket and sendCommandStrip() to know if the problem is in the socket comms or in the RGB565 object.

        K Offline
        K Offline
        Kris Revi
        wrote on last edited by Kris Revi
        #3

        @Kent-Dorfman

        here is qDebug() of RGB565 QJsonArray befor it gets sent
        https://pastebin.com/raw/5tUT02zu

        The sendCommandStrip function is this

        void Socket::sendCommandStrip(const QString &bName, const QJsonValue bValue)
        {
            m_webSocket.sendTextMessage(QJsonDocument(QJsonObject{{bName, bValue}}).toJson(QJsonDocument::Compact));
                            qDebug() << QJsonDocument(QJsonObject{{bName, bValue}}).toJson(QJsonDocument::Compact);
        }
        
        1 Reply Last reply
        0
        • K Offline
          K Offline
          Kris Revi
          wrote on last edited by
          #4

          i need to rethink this! no matter what this array is way to big for the ESP32 mcu to handle! i run out of memory no matter what! :/

          1 Reply Last reply
          0
          • Kent-DorfmanK Offline
            Kent-DorfmanK Offline
            Kent-Dorfman
            wrote on last edited by
            #5

            I think another important consideration is why you are sending the image as a text json object over a socket. The sockets can accept binary data. send it as a series binary chunks, including some control meta-data like dimensions, pixel bit format, and checksum. That will drastically decrease your storage requirements. As a rule nothing wrong with sending integer data in binary over the net. Where is gets crazy is sending floating point data over a network.

            1 Reply Last reply
            3

            • Login

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