Nominate our 2022 Qt Champions!

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

  • 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? :/

  • 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.

  • @Kent-Dorfman

    here is qDebug() of RGB565 QJsonArray befor it gets sent

    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);

  • 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! :/

  • 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.

Log in to reply