# SvgRasterizer

Provides deterministic, dependency-free rasterization of SVG documents.

 Class  

`ChartForgeX.SvgRaster`

**Namespace**

`ChartForgeX.SvgRaster`

**Assembly**

`ChartForgeX`

**Source**

[SvgRasterizer.cs:16](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX/SvgRaster/SvgRasterizer.cs#L16)

**Modifiers**

static

Provides deterministic, dependency-free rasterization of SVG documents.

## Inheritance

- object
- SvgRasterizer

 Filter members   

    Show inherited   

 

## Methods

 `public static SvgRasterizationResult Rasterize(string svg, int? width = null, int? height = null, bool strict = false, SvgRasterFilterOptions? filters = null)` [#](#method-rasterize-string-nullable-system-int32-nullable-system-int32-boolean-chartforgex-svgraster-svgrasterfilteroptions) 

[SvgRasterizer.cs:39](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX/SvgRaster/SvgRasterizer.cs#L39)

Rasterizes SVG and reports encountered unsupported content. Strict mode rejects output with diagnostics.

Parameters

**svg string required**

The SVG document.

**width int? = null optional**

Optional output width.

**height int? = null optional**

Optional output height.

**strict bool = false optional**

Whether to throw instead of returning pixels when loss diagnostics are present.

**filters ChartForgeX.SvgRaster.SvgRasterFilterOptions? = null optional**

Optional explicit bounded native-filter import; null retains existing unsupported-filter diagnostics and bytes.

Returns

 `SvgRasterizationResult` Pixels and bounded diagnostics for the supported SVG subset. 

 ToPng 3 overloads 

 `public static byte[] ToPng(string svg, RasterImageOptions? options = null)` [#](#method-topng-string-chartforgex-core-rasterimageoptions) 

[SvgRasterizer.cs:16](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX/SvgRaster/SvgRasterizer.cs#L16)

Rasterizes an SVG document to PNG using its declared viewport size.

Parameters

**svg string required**

**options ChartForgeX.Core.RasterImageOptions? = null optional**

Returns

 `byte[]` 

 `public static byte[] ToPng(string svg, int? width, int? height, RasterImageOptions? options = null)` [#](#method-topng-string-nullable-system-int32-nullable-system-int32-chartforgex-core-rasterimageoptions) 

[SvgRasterizer.cs:20](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX/SvgRaster/SvgRasterizer.cs#L20)

Rasterizes an SVG document to PNG using optional output dimensions.

Parameters

**svg string required**

**width int? required**

**height int? required**

**options ChartForgeX.Core.RasterImageOptions? = null optional**

Returns

 `byte[]` 

 `public static byte[] ToPng(byte[] svgBytes, int? width = null, int? height = null, RasterImageOptions? options = null)` [#](#method-topng-byte-nullable-system-int32-nullable-system-int32-chartforgex-core-rasterimageoptions) 

[SvgRasterizer.cs:98](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX/SvgRaster/SvgRasterizer.cs#L98)

Rasterizes UTF-8 SVG bytes to PNG.

Parameters

**svgBytes byte[] required**

**width int? = null optional**

**height int? = null optional**

**options ChartForgeX.Core.RasterImageOptions? = null optional**

Returns

 `byte[]` 

 ToRgbaImage 2 overloads 

 `public static RgbaImage ToRgbaImage(string svg, int? width = null, int? height = null)` [#](#method-torgbaimage-string-nullable-system-int32-nullable-system-int32) 

[SvgRasterizer.cs:29](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX/SvgRaster/SvgRasterizer.cs#L29)

Rasterizes an SVG document to RGBA pixels using its declared viewport size or optional output dimensions. Use this instead of [SvgRasterizer.ToPng](/api/chartforgex-svgraster-svgrasterizer/) when the pixels go straight into a composition, so they are not encoded and decoded on the way.

Parameters

**svg string required**

**width int? = null optional**

**height int? = null optional**

Returns

 `RgbaImage` 

 `public static RgbaImage ToRgbaImage(byte[] svgBytes, int? width = null, int? height = null)` [#](#method-torgbaimage-byte-nullable-system-int32-nullable-system-int32) 

[SvgRasterizer.cs:92](https://github.com/EvotecIT/ChartForgeX/blob/main/ChartForgeX/SvgRaster/SvgRasterizer.cs#L92)

Rasterizes UTF-8 SVG bytes to RGBA pixels.

Parameters

**svgBytes byte[] required**

**width int? = null optional**

**height int? = null optional**

Returns

 `RgbaImage` 

## Inherited Methods

 `public virtual bool Equals(object? obj)` [#](#method-equals-object) 

Inherited from object

Parameters

**obj object? required**

Returns

 `bool` 

 `public virtual int GetHashCode()` [#](#method-gethashcode) 

Inherited from object

Returns

 `int` 

 `public Type GetType()` [#](#method-gettype) 

Inherited from object

Returns

 `Type` 

 `public virtual string? ToString()` [#](#method-tostring) 

Inherited from object

Returns

 `string?` 

<!-- PowerForge markdown artifact sha256:E31CEF4B012C7E44EEDE38429F1FD466A7E56B67BDCAE50D0E7DFFC8AA7ACDB3 -->
