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. Example to use QGLShader for 2D image filtering?
Forum Updated to NodeBB v4.3 + New Features

Example to use QGLShader for 2D image filtering?

Scheduled Pinned Locked Moved General and Desktop
4 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.
  • V Offline
    V Offline
    voxel
    wrote on last edited by
    #1

    I'm writing an image filter program using Qt. Basically it reads a QImage from file and applies a few filters (forexample, black & white). I realize pixel by pixel manipulation is too slow when image is of decent size. I wonder if there is any example of utilizing QGLShader (fragment shader) to achieve fast 2D image processing. Ideally we just need to provide an input QImage, write our own filter code in glsl and get an output QImage. Also ideally there should be no QGLWidget involved because the output QImage will just be displayed in a normal QWidget, or not being displayed at all.

    Is there any example for such usage? I looked around and can only find a few examples of how to use QGLShader directly with QGLWidget. What if I just provide a QImage? I'm a little surprised to be honest that there is so little information on that, because this could turn out to be Qt's own "Core Graphics" framework.

    Thank you all,
    Voxel

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Júlio Brito
      wrote on last edited by
      #2

      try to use pointers to do pixel to pixel processing.
      You can retrieve all pixels with Qimage::bits. This return *uchar data from your image.

      http://doc.qt.nokia.com/4.7-snapshot/qimage.html
      http://doc.qt.nokia.com/4.7-snapshot/qimage.html#bits

      1 Reply Last reply
      0
      • V Offline
        V Offline
        voxel
        wrote on last edited by
        #3

        Thanks for your reply. Using pointers does not really solve speed issue. The image is still processed pixel by pixel, while fragment shader does the processing in parallel in GPU. We are talking about 100 times faster not just a minor performance tweak...

        Voxel

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Júlio Brito
          wrote on last edited by
          #4

          i see. ^ ^

          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