Click or drag to resize
LuminanceToAlphaEffect Class
Generates an image with alpha channel set to the luminance of the source image, and color channels set to 0. Use it to make a semitransparent overlay based on the brightness of the source image.
Inheritance Hierarchy
SystemObject
  Microsoft.Graphics.Canvas.EffectsLuminanceToAlphaEffect

Namespace:  Microsoft.Graphics.Canvas.Effects
Assembly:  Microsoft.Graphics.Canvas (in Microsoft.Graphics.Canvas.dll) Version: 0.0.0.0
Syntax
C#
public sealed class LuminanceToAlphaEffect : ICanvasEffect, 
	IGraphicsEffect, IGraphicsEffectSource, ICanvasImage, IDisposable

The LuminanceToAlphaEffect type exposes the following members.

Constructors
  NameDescription
Public methodLuminanceToAlphaEffect
Initializes a new instance of the LuminanceToAlphaEffect class.
Top
Properties
  NameDescription
Public propertyBufferPrecision
Specifies what precision to use for intermediate buffers when drawing this effect.
Public propertyCacheOutput
Enables caching the output from drawing this effect.
Public propertyName
Attaches a user-defined name string to the effect.
Public propertySource
Gets or sets the input source for LuminanceToAlpha effect.
Top
Methods
  NameDescription
Public methodDispose
Releases all resources used by the effect.
Public methodGetBounds(ICanvasResourceCreator)
Retrieves the bounds of this LuminanceToAlphaEffect.
Public methodGetBounds(ICanvasResourceCreator, Matrix3x2)
Retrieves the bounds of this LuminanceToAlphaEffect.
Public methodGetInvalidRectangles
Queries what regions of the effect output have changed since it was last drawn.
Public methodCode exampleGetRequiredSourceRectangle
Queries what part of an effect source image is needed to draw an output region.
Public methodGetRequiredSourceRectangles
Queries what parts of the effect source images are needed to draw an output region.
Public methodInvalidateSourceRectangle
Notifies the effect that one of its source images has changed.
Top
Remarks

This effect sets the alpha channel of the output to the luminance of the input image using the color matrix:

LuminanceToAlpha diagram

This effect consumes and outputs premultiplied alpha images. It won't work on straight alpha images unless they are fully opaque.

Note: because images are stored in a gamma-compensated format, before you calculate the luminance for an image you may wish to first perform inverse gamma correction to get the true color values for the image. Since images are normally stored at 2.2 gamma, you can use GammaTransferEffect with an exponent of (1/2.2).

This Windows Runtime type corresponds to the D2D Luminance to alpha effect.

See Also