2014-03-25 25 views
1

我有一個圖像,我想在它的頂部應用兩個QtGraphicalEffects效果:混合(乘法模式)和色調/飽和度。從documentation報價:移動多個QtGraphicalEffects效果

流水線多重功效在一起是一個簡單的方法來創建甚至 更令人印象深刻的輸出。

Item { 
    Image { 
     id: image1 
     source: "image1.png" 
     visible: false 
     smooth: true 
    } 

    Image { 
     id: image2 
     source: "image2.png" 
     visible: false 
     smooth: true 
    } 

    Blend { 
     id: blendImage 
     anchors.fill: image2 
     source: image2 
     foregroundSource: image1 
     mode: "multiply" 
     visible: false 
    } 

    HueSaturation { 
     anchors.fill: image1 
     source: image2 
     saturation: -1.0 
    } 
} 

此代碼不會產生所需的結果,似乎混合丟失或甚至不認爲是HueSaturation結果的輸出。我怎樣才能把這些效果放在另一個之上?

回答

2

如果您想合併需要疊加的效果(第二個效果的來源必須是您的第一個效果)。

你只需要的HueSaturation源更改爲blendImage

HueSaturation { 
      anchors.fill: image1 
      source: blendImage 
      saturation: -1.0 
    } 

試試這個:

Item { 
     Image { 
      id: image1 
      source: "image1.png" 
      visible: false 
      smooth: true 
     } 

     Image { 
      id: image2 
      source: "image2.png" 
      visible: false 
      smooth: true 
     } 

     Blend { 
      id: blendImage 
      anchors.fill: image2 
      source: image2 
      foregroundSource: image1 
      mode: "multiply" 
      visible: true 
     } 

     HueSaturation { 
      anchors.fill: image1 
      source: blendImage 
      saturation: -1.0 
     } 
    }