private void GetContactImage() { _imageBitmap?.Dispose(); var defaultImage = XamTweet.Forms.Resources.Images.Image.DefaultUser; var cached = _imageCacheService.Cache.FirstOrDefault(x => x.Id.Equals(defaultImage)); if (cached is null) { using (var stream = GetType().GetTypeInfo().Assembly .GetManifestResourceStream(XamTweet.Forms.Resources.Images.Image.DefaultUser)) { var bytes = new byte[stream.Length]; stream.Read(bytes, 0, (int)stream.Length); cached = new XamTweet.CachedImage { Id = defaultImage, Bytes = bytes }; _imageCacheService.Add(cached); } } _imageBitmap = SKBitmap.Decode(cached.Bytes); }
private CachedImage GetResource(string resource) { using (var stream = GetType().GetTypeInfo().Assembly.GetManifestResourceStream(resource)) { var bytes = new byte[stream.Length]; stream.Read(bytes, 0, (int)stream.Length); var cache = new XamTweet.CachedImage { Id = resource, Bytes = bytes }; _imageCacheService.Add(cache); return(cache); } }