Text Saturation in SVG C#

Saturation in an image is described as the intensity of colors. Sometimes you may need to add text in an SVG image and saturate it. In accordance with such scenarios, this article covers how to perform text saturation in SVG images programmatically in C#.

C# API to Saturate Text in SVG Image - Installation

Aspose.SVG for .NET API is capable of creating or manipulating SVG images. You can apply different filters and work with many properties of the Scalable Vector Graphic images, as well as convert the SVG images to supported formats. Simply download the DLL file or run the following NuGet installation command:

PM> Install-Package Aspose.SVG

How to Saturate Text in SVG Image in C#

You can insert text in an SVG image and saturate it with the following steps:

  1. Create an SVGDocument class object.
  2. Create a defs and filter element.
  3. Create a feColorMatrix element and add text to the SVG.
  4. Save the output SVG image.

The following section further elaborates on how to perform these steps in a C# code snippet:

Saturate Text in SVG Image Programmatically in C#

You can saturate text in an SVG image with the following steps:

  1. Create an SVGDocument class object.
  2. Access the root SVG element and set the namespace URL.
  3. Create an SVGDefsElement class object and add it to the SVG element.
  4. Initialize an SVGFEColorMatrixElement class instance and set different values.
  5. Define an SVGTextElement class object and add text to the SVG.
  6. Finally, export the output SVG image with the Save() method.

The code snippet below demonstrates how to create a saturation effect with the color matrix in C#:

Get a Free API License

You may request a free temporary license to evaluate all features of the API to their full capacity.

Conclusion

In this article, you have learned how to apply text saturation in an SVG image programmatically in C#. Whereas, you may take a look at the documentation section to learn various other features included in the API. In case you want to discuss any of your concerns or ambiguity, please feel free to reach out to us at the free support forum.

See Also