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. Fast Bitmap Update
Qt 6.11 is out! See what's new in the release blog

Fast Bitmap Update

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 966 Views 2 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.
  • qt27Q Offline
    qt27Q Offline
    qt27
    wrote on last edited by
    #1

    I have a QGraphicsView with a QGraphicsScene. I use this mostly to display a 16-bit grayscale image but it can also have some other items on it, e.g. circles, lines, text, etc. hence I chose the QGraphicsScene. The user will frequently adjust the brightness and contrast of the image using the mouse. To have this happening smoothly, I need to achieve about 10 updates per second. However, I am only getting about 2 or 3. Here is what I do:

    Initially:
    pImage = new QImage(...)
    pScene = new QGraphicsScene()
    pixmap = QPixmap::fromImage(*image)
    pPixmap = pScene->addPixmap(pixmap)

    Updates:
    for all rows:
    memcpy(pImage->scanLine(y), newData, width)
    newPixmap = QPixmap::fromImage(*pImage)
    pPixmap->setPixmap(pm)

    Especially the fromImage takes a lot of time. How can I achieve the same but much faster? I would also be willing to give up the QGraphicsScene (which is the reason why I need to use QPixmaps rather the QImage) as long as I can still easily draw the circles, lines and text.

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

      Hi! The way to make this really fast is to use OpenGL. You upload the grayscale data to the GPU, and run a shader program on it to change the brightness / constrast.

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved