Beispiel #1
0
        /// <summary>
        /// Gets full or preview image from cache. If missing null is returned.
        /// </summary>
        /// <param name="key">Image key, it can be URL or image Path.</param>
        /// <param name="preview">True for requesting preview image, false if we need full size image.</param>
        /// <returns>Bitmap or null if image doesn't exist in cache.</returns>
        public Bitmap TryGetImage(string key, bool preview)
        {
            Bitmap retBitmap = null;

            var record = IWantToDatabase.GetFileLruCache(key);

            if (record != null)
            {
                _log.InfoFormat("Image with key: '{0}' already stored in cache.", key);
                var data   = (preview) ? record.Preview : record.Data;
                var bitmap = BitmapFactory.DecodeByteArray(data, 0, data.Length);
                retBitmap = bitmap;
            }
            else
            {
                _log.WarnFormat("Image with key: '{0}' missing in cache.", key);
            }

            return(retBitmap);
        }