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. Can't able to change the pixmap color with QLinearGradient
Forum Updated to NodeBB v4.3 + New Features

Can't able to change the pixmap color with QLinearGradient

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 717 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.
  • A Offline
    A Offline
    Aravinth Ravi
    wrote on last edited by
    #1

    I'm using masking operation (Qt::MaskInColor) for the pixmap. Except the masked region from the pixmap, I'm trying to fill the remaining region of the pixmap with the QLinearGradient (color gradient).

    If I did'nt use the masking operation, the entire pixmap is filled with the color gradient (using QLinearGradient). But I want to fill the color gradient in the specific region of the pixmap. I could'nt find a way to do this.

    Provide me some solutions to sort out this issue. Thanks in advance.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You might be interested by the Painting Composition example.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Aravinth Ravi
        wrote on last edited by
        #3

        Hi,
        This is the original image. In this image the background color is purple.Original_img.png

        From the above image we have masked the purple color using Qt::MaskFromColor function. Masked_img.png

        After masking the purple color, I have tried to apply the color gradient on the icon. But I can't apply the color gradient on the icon. The color gradient is getting applied on the whole image. Atlast, I have have managed to apply a solid color to the icon.SolidColor_img.png

        Like the above image, I have tried to fill the linearcolorGradient in the icon instead of solid green color.

        Is this possible to fill the Icon with color gradient?
        Thanks in advance.

        A 1 Reply Last reply
        0
        • A Aravinth Ravi

          Hi,
          This is the original image. In this image the background color is purple.Original_img.png

          From the above image we have masked the purple color using Qt::MaskFromColor function. Masked_img.png

          After masking the purple color, I have tried to apply the color gradient on the icon. But I can't apply the color gradient on the icon. The color gradient is getting applied on the whole image. Atlast, I have have managed to apply a solid color to the icon.SolidColor_img.png

          Like the above image, I have tried to fill the linearcolorGradient in the icon instead of solid green color.

          Is this possible to fill the Icon with color gradient?
          Thanks in advance.

          A Offline
          A Offline
          Aravinth Ravi
          wrote on last edited by
          #4

          Hi @SGaist ,

          Painting composition will fill the color in the entire bounding rect of the given shapes. And also it will not fill the gradient color. Is it possible to fill the gradient color only on the Icon except the background region. Thanks in advance.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Do you mean in a similar fashion as the Wiggly example ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            A 1 Reply Last reply
            0
            • SGaistS SGaist

              Do you mean in a similar fashion as the Wiggly example ?

              A Offline
              A Offline
              Aravinth Ravi
              wrote on last edited by
              #6

              @SGaist,

              In Wiggly widget, we are using lineEdit as a input. But in my application, I'm using a png image as a pixmap and I have to provide color gradient to that pixmap like the below image.
              Sample.png

              And also in wiggly widget, there will be a change in color gradient from letter to letter. But for my application I need a color gradient change in each letter.

              JoeCFDJ 1 Reply Last reply
              0
              • A Aravinth Ravi

                @SGaist,

                In Wiggly widget, we are using lineEdit as a input. But in my application, I'm using a png image as a pixmap and I have to provide color gradient to that pixmap like the below image.
                Sample.png

                And also in wiggly widget, there will be a change in color gradient from letter to letter. But for my application I need a color gradient change in each letter.

                JoeCFDJ Offline
                JoeCFDJ Offline
                JoeCFD
                wrote on last edited by
                #7

                @Aravinth-Ravi
                since you know background color, do a loop through all pixels. If the pixel color is background color, ignore the pixel. Otherwise, apply your gradient.
                https://forum.qt.io/topic/136223/change-pixel-color-of-qpixmap

                A 1 Reply Last reply
                0
                • JoeCFDJ JoeCFD

                  @Aravinth-Ravi
                  since you know background color, do a loop through all pixels. If the pixel color is background color, ignore the pixel. Otherwise, apply your gradient.
                  https://forum.qt.io/topic/136223/change-pixel-color-of-qpixmap

                  A Offline
                  A Offline
                  Aravinth Ravi
                  wrote on last edited by
                  #8

                  Hi @JoeCFD,

                  Thanks, your idea is working. I have iterated through all the pixels and I have ignored the background color pixels. While iterating through the image, I have incremented the RGB channel data values to apply gradient inside the icon.

                  1 Reply Last reply
                  0
                  • A Aravinth Ravi has marked this topic as solved on

                  • Login

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