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. How to get the bitmap from an Qimage
Forum Updated to NodeBB v4.3 + New Features

How to get the bitmap from an Qimage

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 5.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.
  • B Offline
    B Offline
    browser90
    wrote on last edited by
    #1

    Hi guys,

    I need to have the array with the bits from a QImage. I thougth I could do something with the
    @
    QImage myImage;
    myImage.load("clouds.jpg");
    QByteArray ba;
    QBuffer buffer(&ba);
    buffer.open(QIODevice::WriteOnly);
    myImage.save(&buffer, "PNG"); // writes image into ba in PNG format@

    I need that array because then I can have a second array from an image to transform the 2 images and show them back on the screen.

    For example got a background image + a foreground image and then I could merge them that you see the background image only where the foreground image has nothing to show.

    Kind regards,

    1 Reply Last reply
    0
    • M Offline
      M Offline
      miroslav
      wrote on last edited by
      #2

      QImage in memory is practically a two-dimensional array of pixels. See the pixel() and setPixel() methods. The only property of a pixel is a color value.

      Mirko Boehm | mirko@kde.org | KDE e.V.
      FSFE Fellow
      Qt Certified Specialist

      1 Reply Last reply
      0
      • B Offline
        B Offline
        browser90
        wrote on last edited by
        #3

        Oké thanks. I tried the pixel method it gives me this 4293852159 color value back, but I can't do any methods to get the rgb value or the hex value. Do I need to convert this to a QColor first or how?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          miroslav
          wrote on last edited by
          #4

          QRgb is a 32bit (I think) integer value holding the 4 color elements including alpha. You can manipulate the integer values if you are into such things, or load it into a QColor (setRgba()).

          Mirko Boehm | mirko@kde.org | KDE e.V.
          FSFE Fellow
          Qt Certified Specialist

          1 Reply Last reply
          0
          • T Offline
            T Offline
            task_struct
            wrote on last edited by
            #5

            Hi,

            If I understand you right, you want to composite images. You can use "QPainter::setCompositionMode":http://developer.qt.nokia.com/doc/qt-4.8/qpainter.html#setCompositionMode

            "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

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