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. Convert RGBA8888 buffer to jpeg buffer in memory
Qt 6.11 is out! See what's new in the release blog

Convert RGBA8888 buffer to jpeg buffer in memory

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

    Hi,
    I've a buffer that contains RGBA888 ,I want to create another buffer that hold the jpeg format according to RGBA buffer with header and data.
    I would appreciate any idea.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi!

          // prepare image in RGBA8888 format
          QImage img(600, 400, QImage::Format_RGBA8888);
          {
              img.fill(QColor("white"));
              QPainter painter(&img);
              painter.drawLine(0, 0, 600, 400);
              painter.drawLine(0, 400, 600, 0);
          }
      
          // save image as JPEG to buffer
          QByteArray ba; // buffer uses ba as its storage
          QBuffer buf(&ba); // we'll use buf as QIODevice
          buf.open(QIODevice::WriteOnly);
          img.save(&buf, "JPEG");
      
      1 Reply Last reply
      3
      • AlienA Offline
        AlienA Offline
        Alien
        wrote on last edited by
        #3

        Dear @Wieland ,
        Thank you so much.

        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