locked
How to make a color mask / overlay in WPF RRS feed

  • Question

  • My application deals with a lot of images, each one displayed inside a cell of a Grid using an Image control.
    On some of then I need to have a color mask (or overlay): to have it multiplied with a color. Essentially, it's exactly what the property OpacityMask does, but using the RGB channels, not just the alpha channel. I've dug around and could not find a way to do this properly. Please don't tell me I have to use pixel shaders to achieve an effect as simple as this...
    Wednesday, March 4, 2009 11:59 PM

Answers

  • A ShaderEffect is the easiest thing I can think of, as WPF doesn't expose blend modes and even that wouldn't be generic enough for what it sounds like you want to do.  You could always try using WriteableBitmap or your own custom BitmapSource to do the calculation in managed code instead if you're dead set against not using an Effect.
    Thursday, March 5, 2009 12:27 AM

All replies

  • A ShaderEffect is the easiest thing I can think of, as WPF doesn't expose blend modes and even that wouldn't be generic enough for what it sounds like you want to do.  You could always try using WriteableBitmap or your own custom BitmapSource to do the calculation in managed code instead if you're dead set against not using an Effect.
    Thursday, March 5, 2009 12:27 AM
  • In my case I would rather pre-calculate each version of the Image.
    It's just seems so stupid not to have this featured supported, since the OpacityMask already does this. Next time, call it ColorMask and use all the color channels, not just the alpha: it's that simple...
    Thursday, March 5, 2009 9:28 AM