Class LuminanceToAlphaEffect
- Namespace
- PaintDotNet.Direct2D1.Effects
- Assembly
- PaintDotNet.Windows.Core.dll
Use the luminance to alpha effect to set the alpha channel to the luminance of the image and sets
the color channels to 0. You can use the output of this effect to make a semitransparent overlay
based on the brightness of the input image. Or you can use it to make an image mask.
This effect sets the alpha channel of the output to the luminance of the input image using this
color matrix:
R' G' B' A'
┌ ┐
│ 0 0 0 0.2125 │ R
│ 0 0 0 0.7154 │ G
[R' G' B' A'] = [R G B A 1] * │ 0 0 0 0.0721 │ B
│ 0 0 0 0 │ A
│ 0 0 0 0 │ 1
└ ┘
This effect consumes and outputs premultiplied alpha images. The effect won't work on straight
alpha images unless they are fully opaque.
This effect calculates the luminance for the image's color values, which is different than
luma which is calculated by GrayscaleEffect.
See Difference between Luma and Luminance
for more information.
NOTE: Because images are stored in a gamma-compensated format, before you calculate the
luminance for an image you should 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) and then use the output of that effect.
For more information, see Luminance to alpha effect
public sealed class LuminanceToAlphaEffect : DeviceEffect<LuminanceToAlphaEffect.Props>, ISerializable, IDeviceEffect, IDeviceImage, IDirect2DResource, IFactoryProperty, IDeviceEffectProperties, IObjectRef, IIsDisposed, IDisposable, IInternalImpl
- Inheritance
-
LuminanceToAlphaEffect
- Implements
- Inherited Members
- Extension Methods