Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Converting image to RGB16 in array



  • Code

    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(QStringLiteral("pixArt"), RGB565);
    }
    

    Question
    Is it possible to make this smaller in size?
    the reason for this is the ESP32 does not have enough memory for this... when i send this over and use ArduinoJson lib to deserializeJson i end up with error DeserializationError::NoMemory


  • Lifetime Qt Champion

    Hi,

    How much memory do you have available on that device ?



  • @SGaist

    Free Heap Size Befor Matrix : 330604
    *** ESP32-HUB75-MatrixPanel-I2S-DMA: Memory Allocations Complete ***        
    Total memory that was reserved: 132 kB.
    ... of which was used for the DMA Linked List(s): 4 kB.
    Heap Memory Available: 192340 bytes total. Largest free block: 113792 bytes.
    General RAM Available: 123968 bytes total. Largest free block: 113792 bytes.
    Free Heap Size after Matrix : 192196
    [WIFI][STATUS] Connecting to WiFi..
    [WIFI][STATUS] Connected
    Free Heap Size after Wifi : 135128
    Free Heap Size after Socket : 135008
    

    Free Heap Size after Socket : 135008 is what im left with

    this does not include DynamicJsonDocument inData(128*128); (and i belive even 128*128 is not even big enough)
    and
    uint16_t pixelArt[128*128] = { }; i copy the array from json into this and then over to the Matrix Display


  • Lifetime Qt Champion

    You might need to send your image in smaller chunks and process these chunks on your device.



  • Never done that befor


  • Lifetime Qt Champion

    Never done what ?


Log in to reply