QT图片叠加CompositionMode效果一览

时间:2024-03-13 15:36:40
QPixmap tmpPix(pix.size());
tmpPix.fill(Qt::transparent);
QPainter p1(&tmpPix);
p1.setCompositionMode(QPainter::CompositionMode_Source);
p1.drawPixmap(0, 0, pix);
if (canBuild)//可建则用半透明表示
{
	//200表示透明度,数值0表示完全透明,数值255表示不透明
    p1.setCompositionMode(QPainter::CompositionMode_DestinationIn);
	p1.fillRect(tmpPix.rect(), QColor(0, 0, 0, 200));
}
else//不可建则用红色半透明表示
{
	p1.setCompositionMode(QPainter::CompositionMode_ColorBurn);
	p1.fillRect(tmpPix.rect(), QColor(255, 100, 100, 200));
}
p1.end();
pix = tmpPix;
painter->drawPixmap(fzX1 - NODE_WIDTH + thisBuilding.x_draw, fzY1 + NODE_HEIGHT + thisBuilding.y_draw, pix);

先上一段网上差不多的代码,将就看,没那么多时间写帖子

CompositionMode_DestinationIn

QT图片叠加CompositionMode效果一览

CompositionMode_ColorBurn

QT图片叠加CompositionMode效果一览

CompositionMode_ColorDodge

QT图片叠加CompositionMode效果一览

CompositionMode_Darken

QT图片叠加CompositionMode效果一览

CompositionMode_Destination

QT图片叠加CompositionMode效果一览

CompositionMode_DestinationAtop

QT图片叠加CompositionMode效果一览

CompositionMode_DestinationOut

QT图片叠加CompositionMode效果一览

CompositionMode_DestinationOver

QT图片叠加CompositionMode效果一览

CompositionMode_Difference

QT图片叠加CompositionMode效果一览

CompositionMode_Exclusion

QT图片叠加CompositionMode效果一览

CompositionMode_HardLight

QT图片叠加CompositionMode效果一览

CompositionMode_Lighten

QT图片叠加CompositionMode效果一览

CompositionMode_Multiply

QT图片叠加CompositionMode效果一览

CompositionMode_Overlay

QT图片叠加CompositionMode效果一览

CompositionMode_Plus

QT图片叠加CompositionMode效果一览

CompositionMode_Screen

QT图片叠加CompositionMode效果一览

CompositionMode_SoftLight

QT图片叠加CompositionMode效果一览

CompositionMode_Source

QT图片叠加CompositionMode效果一览

CompositionMode_SourceAtop  取交集

QT图片叠加CompositionMode效果一览

CompositionMode_SourceIn  

QT图片叠加CompositionMode效果一览

CompositionMode_SourceOut   这种就直接挖空了

QT图片叠加CompositionMode效果一览

CompositionMode_SourceOver

QT图片叠加CompositionMode效果一览

CompositionMode_Xor  

QT图片叠加CompositionMode效果一览