Paya
Paya

Reputation: 5222

Converting template content to color overlay

I have a custom template, and I want to somehow take the output of ContentPresenter (imagine it as a bitmap), now strip RGB from that bitmap (so only alpha channel remains), and then set RGB on every pixel to white (preserve alpha channel). So how would you do that?

Upvotes: 2

Views: 354

Answers (1)

Emond
Emond

Reputation: 50692

I'd use a PixelShader + Effect on the ContentPresenter if it needs to be a 'live' effect.

See the Shazzam tool to easily create the sources for the effect and the PixelShader.

sampler2D Texture1Sampler : register(S0);

//-----------------
// Pixel Shader
//-----------------

float4 main(float2 uv : TEXCOORD) : COLOR
{
    float4 color = tex2D( Texture1Sampler, uv );
    float4 alphaMaskColor = float4(color.a,color.a,color.a,color.a); //Pre-multiplied Alpha in WPF
    return alphaMaskColor;
}

Upvotes: 2

Related Questions