Thanks for reaching out.
ID2D1SvgDocument does support the opacity attribute, but there are some limitations in Direct2D’s SVG implementation that cause the rendering to differ from full SVG engines.
Why this happens
- Direct2D does not fully support
stop-opacityin gradient stops. It only respectsopacityat the element level. - Complex blending and CSS-based transparency are not fully implemented in Direct2D.
How to fix
- Flatten opacity into RGBA colors: Modify your SVG so gradient stops include alpha in the color instead of using
stop-opacity.\ Example: <stop offset="0" style="stop-color:rgba(26,26,26,255)"/> - Apply opacity programmatically: Use Direct2D APIs to set opacity: svgDocument->SetAttributeValue(L"opacity", D2D1SVGATTRIBUTEPODTYPE_FLOAT, &opacityValue);
- Per-element control:
Retrieve the element and set opacity explicitly: ComPtr<ID2D1SvgElement> circleElement; svgDocument->GetElementById(L"circleId", &circleElement); circleElement->SetAttributeValue(L"opacity", D2D1SVGATTRIBUTEPODTYPE_FLOAT, &opacityValue);References
- Direct2D SVG Overview
- ID2D1SvgDocument Interface
Let me know if the issue persists after following these steps. I’ll be happy to assist further if needed. If the issue has been resolved, Kindly mark the provided solution as "Accept Answer", so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.