Επεξεργασία

Κοινή χρήση μέσω


Gamma transfer effect

Use the gamma transfer effect to map the color intensities of an image using a gamma function created using an amplitude, exponent, and offset you provide for each channel.

The CLSID for this effect is CLSID_D2D1GammaTransfer. To use this effect, add dxguid.lib to the linker dependencies.

Example image

Before
the image before the effect.
After
the image after the transform.
ComPtr<ID2D1Effect> gammaTransferEffect;
m_d2dContext->CreateEffect(CLSID_D2D1GammaTransfer, &gammaTransferEffect);

gammaTransferEffect->SetInput(0, bitmap);

gammaTransferEffect->SetValue(D2D1_GAMMATRANSFER_PROP_RED_EXPONENT, 0.25f);
gammaTransferEffect->SetValue(D2D1_GAMMATRANSFER_PROP_GREEN_EXPONENT, 0.25f);
gammaTransferEffect->SetValue(D2D1_GAMMATRANSFER_PROP_BLUE_EXPONENT, 0.25f);

m_d2dContext->BeginDraw();
m_d2dContext->DrawImage(gammaTransferEffect.Get());
m_d2dContext->EndDraw();

This effect applies a gamma transfer function based on the equation here.

The input pixel intensity is represented as C and the output pixel intensity as C'. C' = Amplitude * CExponent + Offset

This effect works on straight and premultiplied alpha images. The effect outputs premultiplied alpha bitmaps.

Effect properties

Note

For all channels of the gamma transfer properties:

  • The amplitude value is not bounded and is unitless.
  • The exponent value is not bounded and is unitless.
  • The offset value is not bounded and is unitless.
Display name and index enumeration Description
RedAmplitude
D2D1_GAMMATRANSFER_PROP_RED_AMPLITUDE
The amplitude of the gamma transfer function for the Red channel. The type is FLOAT.
The default value is 1.0f.
RedExponent
D2D1_GAMMATRANSFER_PROP_RED_EXPONENT
The exponent of the gamma transfer function for the Red channel. The type is FLOAT.
The default value is 1.0f.
RedOffset
D2D1_GAMMATRANSFER_PROP_RED_OFFSET
The offset of the gamma transfer function for the Red channel. The type is FLOAT.
The default value is 0.0f.
RedDisable
D2D1_GAMMATRANSFER_PROP_RED_DISABLE
If you set this to TRUE it does not apply the transfer function to the Red channel. An identity transfer function is used. If you set this to FALSE it applies the gamma transfer function to the Red channel. The type is BOOL.
The default value is FALSE.
GreenAmplitude
D2D1_GAMMATRANSFER_PROP_GREEN_AMPLITUDE
The amplitude of the gamma transfer function for the Green channel. The type is FLOAT.
The default value is 1.0f.
GreenExponent
D2D1_GAMMATRANSFER_PROP_GREEN_EXPONENT
The exponent of the gamma transfer function for the Green channel. The type is FLOAT.
The default value is 1.0f.
GreenOffset
D2D1_GAMMATRANSFER_PROP_GREEN_OFFSET
The offset of the gamma transfer function for the Green channel. The type is FLOAT.
The default value is 0.0f.
GreenDisable
D2D1_GAMMATRANSFER_PROP_GREEN_DISABLE
If you set this to TRUE it does not apply the transfer function to the Green channel. An identity transfer function is used. If you set this to FALSE it applies the gamma transfer function to the Green channel. The type is BOOL.
The default value is FALSE.
BlueAmplitude
D2D1_GAMMATRANSFER_PROP_BLUE_AMPLITUDE
The amplitude of the gamma transfer function for the Blue channel. The type is FLOAT.
The default value is 1.0f.
BlueExponent
D2D1_GAMMATRANSFER_PROP_BLUE_EXPONENT
The exponent of the gamma transfer function for the Blue channel. The type is FLOAT.
The default value is 1.0f.
BlueOffset
D2D1_GAMMATRANSFER_PROP_BLUE_OFFSET
The offset of the gamma transfer function for the Blue channel. The type is FLOAT.
The default value is 0.0f.
BlueDisable
D2D1_GAMMATRANSFER_PROP_BLUE_DISABLE
If you set this to TRUE it does not apply the transfer function to the Blue channel. An identity transfer function is used. If you set this to FALSE it applies the gamma transfer function to the Blue channel. The type is BOOL.
The default value is FALSE.
AlphaAmplitude
D2D1_GAMMATRANSFER_PROP_ALPHA_AMPLITUDE
The amplitude of the gamma transfer function for the alpha channel. The type is FLOAT.
The default value is 1.0f.
AlphaExponent
D2D1_GAMMATRANSFER_PROP_ALPHA_EXPONENT
The exponent of the gamma transfer function for the alpha channel. The type is FLOAT.
The default value is 1.0f.
AlphaOffset
D2D1_GAMMATRANSFER_PROP_ALPHA_OFFSET
The offset of the gamma transfer function for the alpha channel. The type is FLOAT.
The default value is 0.0f.
AlphaDisable
D2D1_GAMMATRANSFER_PROP_ALPHA_DISABLE
If you set this to TRUE it does not apply the transfer function to the alpha channel. An identity transfer function is used. If you set this to FALSE it applies the gamma transfer function to the alpha channel. The type is BOOL.
The default value is FALSE.
ClampOutput
D2D1_GAMMATRANSFER_PROP_CLAMP_OUTPUT
Whether the effect clamps color values to between 0 and 1 before the effect passes the values to the next effect in the graph. The effect clamps the values before it premultiplies the alpha .
If you set this to TRUE the effect will clamp the values. If you set this to FALSE, the effect will not clamp the color values, but other effects and the output surface may clamp the values if they are not of high enough precision.
The type is BOOL.
The default value is FALSE.

Output bitmap

The output bitmap size is the same as the input bitmap size.

Requirements

Requirement Value
Minimum supported client Windows 8 and Platform Update for Windows 7 [desktop apps | Windows Store apps]
Minimum supported server Windows 8 and Platform Update for Windows 7 [desktop apps | Windows Store apps]
Header d2d1effects.h
Library d2d1.lib, dxguid.lib

ID2D1Effect