Επεξεργασία

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


Linear transfer effect

Use the linear transfer effect to map the color intensities of an image using a linear function created from a list of values you provide for each channel.

The CLSID for this effect is CLSID_D2D1LinearTransfer.

Example image

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

linearTransferEffect->SetInput(0, bitmap);

linearTransferEffect->SetValue(D2D1_LINEARTRANSFER_PROP_RED_Y_INTERCEPT, -1.0f);
linearTransferEffect->SetValue(D2D1_LINEARTRANSFER_PROP_RED_SLOPE, 2.5f);
linearTransferEffect->SetValue(D2D1_LINEARTRANSFER_PROP_GREEN_Y_INTERCEPT, -1.0f);
linearTransferEffect->SetValue(D2D1_LINEARTRANSFER_PROP_GREEN_SLOPE, 5.0f);

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

The linear transfer function is created based on the slope and y-intercept for each channel that you specify. The output pixel intensity C is calculated with the equation: C' = mC + B, where m is the slope of the linear function and B is the Y-intercept of the linear function.

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

Effect properties

Note

For all channels of the linear transfer properties:

  • The Y-intercept is not bounded and is unitless.
  • The slope is not bounded and is unitless.
Display name and index enumeration Type and default value Description
RedYIntercept
D2D1_LINEARTRANSFER_PROP_RED_Y_INTERCEPT
FLOAT
0.0f
The Y-intercept of the linear function for the Red channel.
RedSlope
D2D1_LINEARTRANSFER_PROP_RED_SLOPE
FLOAT
1.0f
The slope of the linear function for the Red channel.
RedDisable
D2D1_LINEARTRANSFER_PROP_RED_DISABLE
BOOL
FALSE
If you set this to TRUE the effect does not apply the transfer function to the Red channel. If you set this to FALSE the effect applies the RedLinearTransfer function to the Red channel.
GreenYIntercept
D2D1_LINEARTRANSFER_PROP_GREEN_Y_INTERCEPT
FLOAT
0.0f
The Y-intercept of the linear function for the Green channel.
GreenSlope
D2D1_LINEARTRANSFER_PROP_GREEN_SLOPE
FLOAT
1.0f
The slope of the linear function for the Green channel.
GreenDisable
D2D1_LINEARTRANSFER_PROP_GREEN_DISABLE
BOOL
FALSE
If you set this to TRUE the effect does not apply the transfer function to the Green channel. If you set this to FALSE it applies the GreenLinearTransfer function to the Green channel.
BlueYIntercept
D2D1_LINEARTRANSFER_PROP_BLUE_Y_INTERCEPT
FLOAT
0.0f
The Y-intercept of the linear function for the Blue channel.
BlueSlope
D2D1_LINEARTRANSFER_PROP_BLUE_SLOPE
FLOAT
1.0f
The slope of the linear function for the Blue channel.
BlueDisable
D2D1_LINEARTRANSFER_PROP_BLUE_DISABLE
BOOL
FALSE
If you set this to TRUE the effect does not apply the transfer function to the Blue channel. If you set this to FALSE it applies the BlueLinearTransfer function to the Blue channel.
AlphaYIntercept
D2D1_LINEARTRANSFER_PROP_ALPHA_Y_INTERCEPT
FLOAT
0.0f
The Y-intercept of the linear function for the Alpha channel.
AlphaSlope
D2D1_LINEARTRANSFER_PROP_ALPHA_SLOPE
FLOAT
0.0f
The slope of the linear function for the Alpha channel.
AlphaDisable
D2D1_LINEARTRANSFER_PROP_ALPHA_DISABLE
BOOL
FALSE
If you set this to TRUE the effect does not apply the transfer function to the Alpha channel. If you set this to FALSE it applies the AlphaLinearTransfer function to the Alpha channel.
ClampOutput
D2D1_LINEARTRANSFER_PROP_CLAMP_OUTPUT
BOOL
FALSE
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.

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