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. Drawing directly manipulated bitmaps fast

Drawing directly manipulated bitmaps fast

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 794 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.
  • A Offline
    A Offline
    Andy32
    wrote on last edited by
    #1

    Hi,

    Usual topic, although I didn't find suitable answer yet.
    Please don't route me to OpenGL as I would like to draw transparent Qt widgets into the scene and AFAIK Qt's OpenGL view is not part of Qt's graphics context.
    I'd use OpenGL as render to texture, than I'd want to draw that texture into Qt context, fast.

    I have tried this sample code. For 640x640 resolution on 20FPS, it eats up 20% CPU on a fast notebook, with Linux and Cinnamon Desktop.

    Is there any more efficient solution?

    J.HilkJ 1 Reply Last reply
    0
    • A Andy32

      Hi,

      Usual topic, although I didn't find suitable answer yet.
      Please don't route me to OpenGL as I would like to draw transparent Qt widgets into the scene and AFAIK Qt's OpenGL view is not part of Qt's graphics context.
      I'd use OpenGL as render to texture, than I'd want to draw that texture into Qt context, fast.

      I have tried this sample code. For 640x640 resolution on 20FPS, it eats up 20% CPU on a fast notebook, with Linux and Cinnamon Desktop.

      Is there any more efficient solution?

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      hi @Andy32 ,

      from the sample code you gave. The most cpu intensive operation would probably be the construction of a new QImage, each cycle.

      Suggestion.

      Keep a QImage in memory and modify pixel that changed (QImage::setPixel)
      However set pixel is pretty slow as well, the docu suggest scanLine() or bits() to edit pixels directly, should be a lot faster.

      And if thats not enough, you could potentially split the Pixel manipulation in sectors and use different Threads for each sector.


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      1
      • A Offline
        A Offline
        Andy32
        wrote on last edited by
        #3

        Thanks for the tip for QImage.bits(). I have tried it out. I do minimal update on bits() in every cycle. It works. The CPU usage is still around 20%. But not the Qt process eats up the CPU rather the cinnamon process. Maybe this efficiency issue is related to Cinnamon's compositor and cannot be improved from Qt side.

        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