Can't able to change the pixmap color with QLinearGradient
-
wrote on 16 Feb 2023, 12:15 last edited by
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.
-
Hi,
You might be interested by the Painting Composition example.
-
wrote on 21 Feb 2023, 04:43 last edited by
Hi,
This is the original image. In this image the background color is purple.From the above image we have masked the purple color using Qt::MaskFromColor function.
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.
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. -
Hi,
This is the original image. In this image the background color is purple.From the above image we have masked the purple color using Qt::MaskFromColor function.
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.
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.wrote on 23 Feb 2023, 07:04 last edited byHi @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.
-
Do you mean in a similar fashion as the Wiggly example ?
-
Do you mean in a similar fashion as the Wiggly example ?
wrote on 24 Feb 2023, 04:55 last edited byIn 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.
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.
-
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.
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.
wrote on 24 Feb 2023, 15:27 last edited by@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 -
@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-qpixmapwrote on 28 Feb 2023, 09:33 last edited byHi @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.
-
7/8