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. QImage color painting question
Qt 6.11 is out! See what's new in the release blog

QImage color painting question

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 5.6k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi, I got a QImage and I want to paint only the red color channel to screen with QPainter.
    I want to paint the red color channel as grayscale, not as red. The blue and green channels should not be painted, I only want information from the red channel.

    What is the best approach?

    Thank you :)

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

      One simplistic way is to use iterate over the pixels of your QImage and create a new filtered QImage where each pixel has a value of (r, r, r) where r is the red channel of your original image. Then display your new image.

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

        If your image is going to be changing often then it might be better to do this in hardware by using OpenGL and a suitable fragment shader.

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

          Thank you, yes, my image is updated 20 times a second, so I want to avoid heavy operations.

          Is there no easy way around this? Do I really need to manipulate the image in such a way?

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

            For that kind of refresh rate I would definitely look at OpenGL so that the heavy lifting is done in hardware rather than software (assuming you have an accelerated OpenGL implementation).

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              I agree: you'll have to turn to HW accelerated methods for this, and OpenGL would be the first candidate for that.

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

                Okay, thank you :)

                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