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. Writing QImage into a buffer always returns error

Writing QImage into a buffer always returns error

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.5k 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.
  • R Offline
    R Offline
    ras123
    wrote on last edited by
    #1

    Hi,
    I tried to write a QImage into buffer as follows,
    @
    bool MainWindow::somefunction(QImage &image)
    {
    QByteArray bytes;
    QBuffer buffer(&bytes);

    buffer.open(QIODevice::WriteOnly);
    
    if(image.save(&buffer, "JPG"))
    {
        qDebug() << "Error in writing to buffer";
        ui->imgLabel->setPixmap(QPixmap::fromImage(image)); // A test write, and it displays correctly in imgLabel
        buffer.close();
        return false;
    }
    buffer.close();
    return true;
    

    }
    @
    The image contained in QImage is verified using a write to imgLabel, but the above code always retuns error

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      [quote author="ras123" date="1361806714"]
      @
      if(image.save(&buffer, "JPG"))
      {
      qDebug() << "Error in writing to buffer";
      @
      [/quote]That displays an error message when you succeed :)

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • R Offline
        R Offline
        ras123
        wrote on last edited by
        #3

        Thank you, I missed the not sign

        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