Table of Contents

Class BitmapImageExtensions

Namespace
Akavache.Drawing
Assembly
Akavache.Drawing.dll

Provides extension methods associated with the Splat.IBitmap interface.

public static class BitmapImageExtensions
Inheritance
BitmapImageExtensions

Methods

ImageToBytes(IBitmap)

Convert an IBitmap to a byte array asynchronously.

public static IObservable<byte[]> ImageToBytes(this IBitmap image)

Parameters

image IBitmap

The bitmap image to convert.

Returns

IObservable<byte[]>

A Future result representing the byte array.

LoadImage(IBlobCache, string, float?, float?)

Load an image from the blob cache.

public static IObservable<IBitmap> LoadImage(this IBlobCache blobCache, string key, float? desiredWidth = null, float? desiredHeight = null)

Parameters

blobCache IBlobCache

The blob cache to load the image from.

key string

The key to look up in the cache.

desiredWidth float?

Optional desired width, if not specified will be the default size.

desiredHeight float?

Optional desired height, if not specified will be the default size.

Returns

IObservable<IBitmap>

A Future result representing the bitmap image. blobCache Observable is guaranteed to be returned on the UI thread.

LoadImageFromUrl(IBlobCache, string, bool, float?, float?, DateTimeOffset?)

A combination of DownloadUrl and LoadImage, this method fetches an image from a remote URL (using the cached value if possible) and returns the image.

public static IObservable<IBitmap> LoadImageFromUrl(this IBlobCache blobCache, string url, bool fetchAlways = false, float? desiredWidth = null, float? desiredHeight = null, DateTimeOffset? absoluteExpiration = null)

Parameters

blobCache IBlobCache

The blob cache to load the image from if available.

url string

The URL to download.

fetchAlways bool

If we should always fetch the image from the URL even if we have one in the blob.

desiredWidth float?

Optional desired width, if not specified will be the default size.

desiredHeight float?

Optional desired height, if not specified will be the default size.

absoluteExpiration DateTimeOffset?

An optional expiration date.

Returns

IObservable<IBitmap>

A Future result representing the bitmap image. blobCache Observable is guaranteed to be returned on the UI thread.

LoadImageFromUrl(IBlobCache, string, string, bool, float?, float?, DateTimeOffset?)

A combination of DownloadUrl and LoadImage, this method fetches an image from a remote URL (using the cached value if possible) and returns the image.

public static IObservable<IBitmap> LoadImageFromUrl(this IBlobCache blobCache, string key, string url, bool fetchAlways = false, float? desiredWidth = null, float? desiredHeight = null, DateTimeOffset? absoluteExpiration = null)

Parameters

blobCache IBlobCache

The blob cache to load the image from if available.

key string

The key to store with.

url string

The URL to download.

fetchAlways bool

If we should always fetch the image from the URL even if we have one in the blob.

desiredWidth float?

Optional desired width, if not specified will be the default size.

desiredHeight float?

Optional desired height, if not specified will be the default size.

absoluteExpiration DateTimeOffset?

An optional expiration date.

Returns

IObservable<IBitmap>

A Future result representing the bitmap image. blobCache Observable is guaranteed to be returned on the UI thread.

LoadImageFromUrl(IBlobCache, string, Uri, bool, float?, float?, DateTimeOffset?)

A combination of DownloadUrl and LoadImage, this method fetches an image from a remote URL (using the cached value if possible) and returns the image.

public static IObservable<IBitmap> LoadImageFromUrl(this IBlobCache blobCache, string key, Uri url, bool fetchAlways = false, float? desiredWidth = null, float? desiredHeight = null, DateTimeOffset? absoluteExpiration = null)

Parameters

blobCache IBlobCache

The blob cache to load the image from if available.

key string

The key to store with.

url Uri

The URL to download.

fetchAlways bool

If we should always fetch the image from the URL even if we have one in the blob.

desiredWidth float?

Optional desired width, if not specified will be the default size.

desiredHeight float?

Optional desired height, if not specified will be the default size.

absoluteExpiration DateTimeOffset?

An optional expiration date.

Returns

IObservable<IBitmap>

A Future result representing the bitmap image. blobCache Observable is guaranteed to be returned on the UI thread.

LoadImageFromUrl(IBlobCache, Uri, bool, float?, float?, DateTimeOffset?)

A combination of DownloadUrl and LoadImage, this method fetches an image from a remote URL (using the cached value if possible) and returns the image.

public static IObservable<IBitmap> LoadImageFromUrl(this IBlobCache blobCache, Uri url, bool fetchAlways = false, float? desiredWidth = null, float? desiredHeight = null, DateTimeOffset? absoluteExpiration = null)

Parameters

blobCache IBlobCache

The blob cache to load the image from if available.

url Uri

The URL to download.

fetchAlways bool

If we should always fetch the image from the URL even if we have one in the blob.

desiredWidth float?

Optional desired width, if not specified will be the default size.

desiredHeight float?

Optional desired height, if not specified will be the default size.

absoluteExpiration DateTimeOffset?

An optional expiration date.

Returns

IObservable<IBitmap>

A Future result representing the bitmap image. blobCache Observable is guaranteed to be returned on the UI thread.

SaveImage(IBlobCache, string, IBitmap, DateTimeOffset?)

Save an image to the blob cache.

public static IObservable<Unit> SaveImage(this IBlobCache blobCache, string key, IBitmap image, DateTimeOffset? absoluteExpiration = null)

Parameters

blobCache IBlobCache

The blob cache to save the image to.

key string

The key to associate with the image.

image IBitmap

The bitmap image to save.

absoluteExpiration DateTimeOffset?

An optional expiration date.

Returns

IObservable<Unit>

A Future result representing the completion of the save operation.

ThrowOnBadImageBuffer(byte[])

Converts bad image buffers into an exception.

public static IObservable<byte[]> ThrowOnBadImageBuffer(this byte[] compressedImage)

Parameters

compressedImage byte[]

The compressed image buffer to check.

Returns

IObservable<byte[]>

The byte[], or OnError if the buffer is corrupt (empty or too small).