在以transparent填充的QPixmap上用红色画笔画出了线,现需要擦除部分红色,恢复出原来的透明色。
使用QPainter::CompositionMode 图像叠加模式
下图简单示意了10种模式:
在Qt的官方文档里我们也找到了具体模式的解释
Constant |
Value |
Description |
QPainter::CompositionMode_SourceOver |
0 |
This is the default mode. The alpha of the source is used to blend the pixel on top of the destination. |
QPainter::CompositionMode_DestinationOver |
1 |
The alpha of the destination is used to blend it on top of the source pixels. This mode is the inverse of CompositionM |