Show / Hide Table of Contents

Method CreateSwatchAsync

CreateSwatchAsync(Double)

Creates a swatch image of this symbol using the default size and a transparent background.

Declaration
public virtual Task<RuntimeImage> CreateSwatchAsync(double dpi = 96)
Parameters
Type Name Description
System.Double dpi

Pixel density (dots per inch) to use when creating the swatch. Default is 96.

Returns
Type Description
System.Threading.Tasks.Task<RuntimeImage>

The task object representing the asynchronous create swatch operation. The value of the task result is a RuntimeImage object.

Remarks

Dimensions of the created image will be at least 20x20 pixels (at 96 dpi), and may be larger depending on symbol size. Minimum swatch size scales with dpi. Note that if the swatch is created without an explicit size or geometry, an accurate representation of symbol patterns might not be captured in the output image.

Applies to

Platforms and versions
TargetVersions
.NET Standard 2.0100.3 - 200.7
.NET100.13 - 200.7
.NET Windows100.13 - 200.7
.NET Android200.0 - 200.7
.NET iOS200.0 - 200.7
.NET Framework100.0 - 200.7
Xamarin.Android100.0 - 100.15
Xamarin.iOS100.0 - 100.15
UWP100.0 - 200.7

CreateSwatchAsync(Color, Double)

Creates a swatch image of this symbol, using the default sizing and a transparent background.

Declaration
public Task<RuntimeImage> CreateSwatchAsync(Color backgroundColor, double dpi = 96)
Parameters
Type Name Description
System.Drawing.Color backgroundColor

The image background color.

System.Double dpi

Pixel density (dots per inch) to use when creating the swatch. Default is 96.

Returns
Type Description
System.Threading.Tasks.Task<RuntimeImage>

The task object representing the asynchronous create swatch operation. The value of the task result is a RuntimeImage object.

Remarks

Dimensions of the created image will be at least 20x20 pixels (at 96 dpi), and may be larger depending on symbol size. Minimum swatch size scales with dpi. Note that if the swatch is created without an explicit size or geometry, an accurate representation of symbol patterns might not be captured in the output image.

Applies to

Platforms and versions
TargetVersions
.NET Standard 2.0100.3 - 200.7
.NET100.13 - 200.7
.NET Windows100.13 - 200.7
.NET Android200.2 - 200.7
.NET iOS200.0 - 200.7
.NET Framework100.3 - 200.7
Xamarin.Android100.0 - 100.14
Xamarin.iOS100.0 - 100.15
UWP100.3 - 200.7

CreateSwatchAsync(Int32, Int32, Single, Color, Geometry)

Creates a swatch image of this symbol, with the specified image size, dpi, background color, and geometry.

Declaration
public Task<RuntimeImage> CreateSwatchAsync(int widthPixels, int heightPixels, float dpi, Color backgroundColor, Geometry geometry)
Parameters
Type Name Description
System.Int32 widthPixels

The width of the swatch in device-independent pixels (DIPs).

System.Int32 heightPixels

The height of the swatch in device-independent pixels (DIPs).

System.Single dpi

Pixel density (dots per inch) to use when creating the swatch.

System.Drawing.Color backgroundColor

The image background color.

Geometry geometry

The custom geometry to be drawn in the swatch image.

Returns
Type Description
System.Threading.Tasks.Task<RuntimeImage>

The task object representing the asynchronous create swatch operation. The value of the task result is a RuntimeImage object.

Remarks

widthPixels and heightPixels may need to be adjusted if dpi is different from its default value of 96. This method does not scale the symbol in order to fit or fill the entire image. The symbol is rendered at its actual size, which may result in some cropping or padding.

The geometry should be specified DIPs, with the point {0,0} located at the centerpoint of the swatch image. The X-axis increases towards the right-hand side of the swatch image. The Y-axis increases towards the top of the swatch image. Geometry type should correspond to symbol type: MapPoint for MarkerSymbol, Polyline for LineSymbol, and Polygon for FillSymbol. Given geometry's spatial reference is ignored.

Applies to

Platforms and versions
TargetVersions
.NET Standard 2.0100.3 - 200.7
.NET100.13 - 200.7
.NET Windows100.13 - 200.7
.NET Android200.2 - 200.7
.NET iOS200.0 - 200.7
.NET Framework100.3 - 200.7
Xamarin.Android100.0 - 100.14
Xamarin.iOS100.0 - 100.15
UWP100.3 - 200.7

CreateSwatchAsync(Int32, Int32, Double, Color)

Creates a swatch image of this symbol, scaled to fit the specified dimensions.

Declaration
public Task<RuntimeImage> CreateSwatchAsync(int widthPixels, int heightPixels, double dpi, Color backgroundColor)
Parameters
Type Name Description
System.Int32 widthPixels

The width of the swatch in device-independent pixels (DIPs).

System.Int32 heightPixels

The height of the swatch in device-independent pixels (DIPs).

System.Double dpi

Pixel density (dots per inch) to use when creating the swatch.

System.Drawing.Color backgroundColor

The background color of the image.

Returns
Type Description
System.Threading.Tasks.Task<RuntimeImage>

The task object representing the asynchronous create swatch operation. The value of the task result is a RuntimeImage object.

Remarks

This method will scale the symbol up or down in order to fill the entire image. Symbol's aspect ratio will be preserved.

Applies to

Platforms and versions
TargetVersions
.NET Standard 2.0100.3 - 200.7
.NET100.13 - 200.7
.NET Windows100.13 - 200.7
.NET Android200.2 - 200.7
.NET iOS200.0 - 200.7
.NET Framework100.3 - 200.7
Xamarin.Android100.1 - 100.14
Xamarin.iOS100.1 - 100.15
UWP100.3 - 200.7
In This Article
Back to top Copyright © 2022 Esri.