Table of Contents

Class SkiaImageManager

Namespace
DrawnUi.Draw
Assembly
DrawnUi.Maui.dll
public class SkiaImageManager : IDisposable
Inheritance
SkiaImageManager
Implements
Inherited Members
Extension Methods

Constructors

SkiaImageManager()

public SkiaImageManager()

Fields

CacheLongevitySecs

Caching provider setting

public static int CacheLongevitySecs

Field Value

int

EnableHttpRetry

Controls whether LoadImageFromInternetAsync should use retry logic. Default is true for iOS/Windows (where it's the fallback when Nuke/Glide is disabled), false for Android (uses Glide retry).

public static bool EnableHttpRetry

Field Value

bool

HttpRetryMaxAttempts

Maximum number of retry attempts for HTTP image loading. Only applies when EnableHttpRetry is true.

public static int HttpRetryMaxAttempts

Field Value

int

LoadLocalAsync

Normally we load local images in a synchronous manner, and remote in async one. Set this to true if you want to load load images async too.

public static bool LoadLocalAsync

Field Value

bool

LogEnabled

public static bool LogEnabled

Field Value

bool

NativeFilePrefix

Convention for local files saved in native platform. Shared resources from Resources/Raw/ do not need this prefix.

public static string NativeFilePrefix

Field Value

string

ReuseBitmaps

If set to true will not return clones for same sources, but will just return the existing cached SKBitmap reference. Useful if you have a lot on images reusing same sources, but you have to be carefull not to dispose the shared image. SkiaImage is aware of this setting and will keep a cached SKBitmap from being disposed.

public static bool ReuseBitmaps

Field Value

bool

Properties

Instance

public static SkiaImageManager Instance { get; }

Property Value

SkiaImageManager

IsDisposed

public bool IsDisposed { get; protected set; }

Property Value

bool

IsLoadingLocked

public bool IsLoadingLocked { get; set; }

Property Value

bool

IsOffline

public bool IsOffline { get; protected set; }

Property Value

bool

UseCache

public static bool UseCache { get; set; }

Property Value

bool

Methods

AddToCache(string, SKBitmap, int)

Returns false if key already exists

public bool AddToCache(string uri, SKBitmap bitmap, int cacheLongevitySecs)

Parameters

uri string
bitmap SKBitmap
cacheLongevitySecs int

Returns

bool

CancelAll()

public void CancelAll()

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

GetFromCache(string)

Return bitmap from cache if existing, respects the ReuseBitmaps flag.

public SKBitmap GetFromCache(string url)

Parameters

url string

Returns

SKBitmap

GetFromCacheInternal(string)

Used my manager for cache organization. You should use GetFromCache for custom controls instead.

public SKBitmap GetFromCacheInternal(string url)

Parameters

url string

Returns

SKBitmap

GetUriFromImageSource(ImageSource)

public static string GetUriFromImageSource(ImageSource source)

Parameters

source ImageSource

Returns

string

LoadFromFile(string, CancellationToken)

public static Task<SKBitmap> LoadFromFile(string filename, CancellationToken cancel)

Parameters

filename string
cancel CancellationToken

Returns

Task<SKBitmap>

LoadImageAsync(ImageSource, CancellationToken)

Direct load, without any queue or manager cache, for internal use. Please use LoadImageManagedAsync instead.

public virtual Task<SKBitmap> LoadImageAsync(ImageSource source, CancellationToken token)

Parameters

source ImageSource
token CancellationToken

Returns

Task<SKBitmap>

LoadImageFromInternetAsync(UriImageSource, CancellationToken)

public static Task<SKBitmap> LoadImageFromInternetAsync(UriImageSource uriSource, CancellationToken cancel)

Parameters

uriSource UriImageSource
cancel CancellationToken

Returns

Task<SKBitmap>

LoadImageManagedAsync(ImageSource, CancellationTokenSource, LoadPriority)

Uses queue and manager cache

public virtual Task<SKBitmap> LoadImageManagedAsync(ImageSource source, CancellationTokenSource token, LoadPriority priority = LoadPriority.Normal)

Parameters

source ImageSource
token CancellationTokenSource
priority LoadPriority

Returns

Task<SKBitmap>

LoadImageOnPlatformAsync(ImageSource, CancellationToken)

public static Task<SKBitmap> LoadImageOnPlatformAsync(ImageSource source, CancellationToken cancel)

Parameters

source ImageSource
cancel CancellationToken

Returns

Task<SKBitmap>

Preload(ImageSource, CancellationTokenSource)

public Task Preload(ImageSource source, CancellationTokenSource cts)

Parameters

source ImageSource
cts CancellationTokenSource

Returns

Task

PreloadBanners<T>(IList<T>, CancellationTokenSource)

public virtual Task PreloadBanners<T>(IList<T> list, CancellationTokenSource cancel = null) where T : IHasBanner

Parameters

list IList<T>
cancel CancellationTokenSource

Returns

Task

Type Parameters

T

PreloadImage(ImageSource, CancellationTokenSource)

Preloads an image from the given source.

public virtual Task PreloadImage(ImageSource source, CancellationTokenSource cancel = null)

Parameters

source ImageSource

The image source to preload

cancel CancellationTokenSource

Returns

Task

PreloadImage(string, CancellationTokenSource)

public virtual Task PreloadImage(string source, CancellationTokenSource cancel = null)

Parameters

source string
cancel CancellationTokenSource

Returns

Task

PreloadImages(IList<string>, CancellationTokenSource)

public virtual Task PreloadImages(IList<string> list, CancellationTokenSource cancel = null)

Parameters

list IList<string>
cancel CancellationTokenSource

Returns

Task

TraceLog(string)

public static void TraceLog(string message)

Parameters

message string

UpdateInCache(string, SKBitmap, int)

public void UpdateInCache(string uri, SKBitmap bitmap, int cacheLongevityMinutes)

Parameters

uri string
bitmap SKBitmap
cacheLongevityMinutes int

Events

CanReload

public event EventHandler CanReload

Event Type

EventHandler