IXpsOMObjectFactory::CreateLinearGradientBrush method (xpsobjectmodel.h)
Creates an IXpsOMLinearGradientBrush interface.
Syntax
HRESULT CreateLinearGradientBrush(
[in] IXpsOMGradientStop *gradStop1,
[in] IXpsOMGradientStop *gradStop2,
[in] const XPS_POINT *startPoint,
[in] const XPS_POINT *endPoint,
[out, retval] IXpsOMLinearGradientBrush **linearGradientBrush
);
Parameters
[in] gradStop1
The IXpsOMGradientStop interface that specifies the gradient properties at the beginning of the gradient's vector. This parameter must not be NULL.
[in] gradStop2
The IXpsOMGradientStop interface that specifies the gradient properties at the end of the gradient's vector. This parameter must not be NULL.
[in] startPoint
The XPS_POINT structure that contains the coordinates of the start point in two-dimensional space.
[in] endPoint
The XPS_POINT structure that contains the coordinates of the end point in two-dimensional space.
[out, retval] linearGradientBrush
A pointer to the new IXpsOMLinearGradientBrush interface.
Return value
The method returns an HRESULT. Possible values include, but are not limited to, those in the table that follows. For information about XPS document API return values that are not listed in this table, see XPS Document Errors.
Return code | Description |
---|---|
|
The method succeeded. |
|
The point specified by either startPoint or endPoint was not valid. The members of the XPS_POINT structure must contain valid and finite floating-point values. |
|
gradStop1, gradStop2, startPoint, figure, or linearGradientBrush is NULL. |
|
gradStop1 or gradStop1 does not point to a recognized interface implementation. Custom implementation of XPS Document API interfaces is not supported. |
Remarks
The gradient region of a linear gradient is the area between and including the start and end points and extending in both directions at a right angle to the gradient path. The spread area is the area of the geometry that lies outside the gradient region.
Gradient stops define the color at specific locations along the gradient path. In the illustration, gradient stop 0, specified by the gradStop1 parameter, is located at the start point of the gradient path, and gradient stop 1, specified by the gradStop2 parameter, is at the end point.
As shown in the illustration that follows, the start and end points of a linear gradient are also the start and end points of the gradient path, which is the straight line that connects those points.
The code example that follows illustrates how this method is used to create a new interface.
IXpsOMLinearGradientBrush *newInterface;
// The following values are defined outside of
// this example.
// IXpsOMGradientStop *gradStop1, *gradStop2;
// XPS_POINT startPoint, endPoint;
// Note the implicit requirement that CoInitializeEx
// has previously been called from this thread.
hr = CoCreateInstance(
__uuidof(XpsOMObjectFactory),
NULL,
CLSCTX_INPROC_SERVER,
_uuidof(IXpsOMObjectFactory),
reinterpret_cast<LPVOID*>(&xpsFactory)
);
if (SUCCEEDED(hr))
{
hr = xpsFactory->CreateLinearGradientBrush (
gradStop1,
gradStop2,
&startPoint,
&endPoint,
&newInterface);
if (SUCCEEDED(hr))
{
// use newInterface
newInterface->Release();
}
xpsFactory->Release();
}
else
{
// evaluate HRESULT error returned in hr
}
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | UWP apps] |
Minimum supported server | Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | UWP apps] |
Target Platform | Windows |
Header | xpsobjectmodel.h |