Class ImageExtensions
- Namespace
- Akavache
- Assembly
- Akavache.dll
Extension methods for working with images and bitmaps in the cache.
public static class ImageExtensions
- Inheritance
-
ImageExtensions
Methods
IsValidImageFormat(byte[])
Validates that the provided bytes represent a valid image format by checking file headers.
public static bool IsValidImageFormat(this byte[] imageBytes)
Parameters
imageBytesbyte[]The image bytes to validate.
Returns
- bool
trueif the bytes appear to be a valid image format; otherwise,false.
LoadImageBytes(IBlobCache, string)
Loads image data from the blob cache as raw bytes.
public static IObservable<byte[]> LoadImageBytes(this IBlobCache blobCache, string key)
Parameters
blobCacheIBlobCacheThe blob cache to load the image from.
keystringThe cache key to look up.
Returns
- IObservable<byte[]>
An observable that emits the image bytes.
LoadImageBytesFromUrl(IBlobCache, string, bool, DateTimeOffset?)
Downloads an image from a remote URL and returns the image bytes. This method combines DownloadUrl and LoadImageBytes functionality, using cached values when possible.
public static IObservable<byte[]> LoadImageBytesFromUrl(this IBlobCache blobCache, string url, bool fetchAlways = false, DateTimeOffset? absoluteExpiration = null)
Parameters
blobCacheIBlobCacheThe blob cache to store and retrieve the image data.
urlstringThe URL to download the image from.
fetchAlwaysboolA value indicating whether to always fetch the image from the URL, bypassing the cache.
absoluteExpirationDateTimeOffset?An optional expiration date for the cached image data.
Returns
- IObservable<byte[]>
An observable that emits the image bytes.
LoadImageBytesFromUrl(IBlobCache, string, string, bool, DateTimeOffset?)
A combination of DownloadUrl and LoadImageBytes, this method fetches an image from a remote URL (using the cached value if possible) and returns the image bytes.
public static IObservable<byte[]> LoadImageBytesFromUrl(this IBlobCache blobCache, string key, string url, bool fetchAlways = false, DateTimeOffset? absoluteExpiration = null)
Parameters
blobCacheIBlobCacheThe blob cache to load the image from if available.
keystringThe key to store with.
urlstringThe URL to download.
fetchAlwaysboolIf we should always fetch the image from the URL even if we have one in the blob.
absoluteExpirationDateTimeOffset?An optional expiration date.
Returns
- IObservable<byte[]>
A Future result representing the image bytes.
LoadImageBytesFromUrl(IBlobCache, string, Uri, bool, DateTimeOffset?)
A combination of DownloadUrl and LoadImageBytes, this method fetches an image from a remote URL (using the cached value if possible) and returns the image bytes.
public static IObservable<byte[]> LoadImageBytesFromUrl(this IBlobCache blobCache, string key, Uri url, bool fetchAlways = false, DateTimeOffset? absoluteExpiration = null)
Parameters
blobCacheIBlobCacheThe blob cache to load the image from if available.
keystringThe key to store with.
urlUriThe URL to download.
fetchAlwaysboolIf we should always fetch the image from the URL even if we have one in the blob.
absoluteExpirationDateTimeOffset?An optional expiration date.
Returns
- IObservable<byte[]>
A Future result representing the image bytes.
LoadImageBytesFromUrl(IBlobCache, Uri, bool, DateTimeOffset?)
A combination of DownloadUrl and LoadImageBytes, this method fetches an image from a remote URL (using the cached value if possible) and returns the image bytes.
public static IObservable<byte[]> LoadImageBytesFromUrl(this IBlobCache blobCache, Uri url, bool fetchAlways = false, DateTimeOffset? absoluteExpiration = null)
Parameters
blobCacheIBlobCacheThe blob cache to load the image from if available.
urlUriThe URL to download.
fetchAlwaysboolIf we should always fetch the image from the URL even if we have one in the blob.
absoluteExpirationDateTimeOffset?An optional expiration date.
Returns
- IObservable<byte[]>
A Future result representing the image bytes.
ThrowOnBadImageBuffer(byte[])
Validates image buffer data and throws an exception if the buffer is invalid.
public static IObservable<byte[]> ThrowOnBadImageBuffer(this byte[] compressedImage)
Parameters
compressedImagebyte[]The compressed image buffer to validate.
Returns
- IObservable<byte[]>
An observable that emits the byte array if valid, or signals an error if the buffer is corrupt.