ID2D1Geometry::Outline methods

Computes the outline of the geometry and writes the result to an ID2D1SimplifiedGeometrySink.

Overload list

Method Description
Outline(D2D1_MATRIX_3X2_F&,ID2D1SimplifiedGeometrySink*) Computes the outline of the geometry and writes the result to an ID2D1SimplifiedGeometrySink.
Outline(D2D1_MATRIX_3X2_F*,ID2D1SimplifiedGeometrySink*) Computes the outline of the geometry and writes the result to an ID2D1SimplifiedGeometrySink.
Outline(D2D1_MATRIX_3X2_F&,FLOAT,ID2D1SimplifiedGeometrySink*) Computes the outline of the geometry and writes the result to an ID2D1SimplifiedGeometrySink.
Outline(D2D1_MATRIX_3X2_F*,FLOAT,ID2D1SimplifiedGeometrySink*) Computes the outline of the geometry and writes the result to an ID2D1SimplifiedGeometrySink.

Remarks

The Outline method allows the caller to produce a geometry with an equivalent fill to the input geometry, with the following additional properties:

  • The output geometry contains no transverse intersections; that is, segments may touch, but they never cross.
  • The outermost figures in the output geometry are all oriented counterclockwise.
  • The output geometry is fill-mode invariant; that is, the fill of the geometry does not depend on the choice of the fill mode. For more information about the fill mode, see D2D1_FILL_MODE.

Additionally, the Outline method can be useful in removing redundant portions of said geometries to simplify complex geometries. It can also be useful in combination with ID2D1GeometryGroup to create unions among several geometries simultaneously.

Examples

The following code shows how to use Outline to construct an equivalent geometry with no self-intersections. It uses the default flattening tolerance and hence should not be used with very small geometries.

HRESULT D2DOutline(
    ID2D1Geometry *pGeometry,
    ID2D1Geometry **ppGeometry
    )
{
    HRESULT hr;
    ID2D1Factory *pFactory = NULL;
    pGeometry->GetFactory(&pFactory);

    ID2D1PathGeometry *pPathGeometry = NULL;
    hr = pFactory->CreatePathGeometry(&pPathGeometry);

    if (SUCCEEDED(hr))
    {
        ID2D1GeometrySink *pSink = NULL;
        hr = pPathGeometry->Open(&pSink);

        if (SUCCEEDED(hr))
        {
            hr = pGeometry->Outline(NULL, pSink);

            if (SUCCEEDED(hr))
            {
                hr = pSink->Close();

                if (SUCCEEDED(hr))
                {
                    *ppGeometry = pPathGeometry;
                    (*ppGeometry)->AddRef();
                }
            }
            pSink->Release();
        }
        pPathGeometry->Release();
    }

    pFactory->Release();

    return hr;
}

Requirements

Requirement Value
Library
D2d1.lib
DLL
D2d1.dll

See also

ID2D1Geometry