K
K
Kirill Romanov2014-08-10 00:54:09
Qt
Kirill Romanov, 2014-08-10 00:54:09

How to remove alpha channel in Qt?

How can one remove the alpha channel from a QPixmap (replace the transparent area with white or black)?
For example, this terminal command works as it should

find . -name "*.png" -exec convert {} -background black -flatten +matte {}.converted.png \;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Lerg, 2014-08-10
@Lerg

Convert to a QImage using the toImage() method and then either use the convertToFormat() method or use the pixel(), setPixel() methods and iterate through all the pixels and blend them with the desired color and set the alpha channel to the maximum.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question