void SetImagePlaceholder()
        {
            if (Element.ImagePlaceholder != null)
            {
                var placeholder = Element.ImagePlaceholder as FileImageSource;
                if (placeholder != null && placeholder.File != null)
                {
                    var resourceID = UIHelper.GetDrawableResource(placeholder);
                    //Bitmap imageBitmap = BitmapFactory.DecodeResource(Context.Resources, resourceID);

                    //SetImageCorners(imageBitmap);

                    if (resourceID > 0)
                    {
                        Bitmap imageBitmap = ImageCache.Instance.Get(resourceID.ToString());
                        if (imageBitmap == null)
                        {
                            BitmapWorkerTask task = new BitmapWorkerTask(imageView, -1, -1, ImageCache.Instance);
                            imageView.SetImageDrawable(new AsyncDrawable(imageView.Resources, null, task));
                            task.Execute(resourceID);
                            task.Finished += (s, e) =>
                                             SetImageCorners(e);
                        }
                        else
                        {
                            SetImageCorners(imageBitmap);
                        }
                    }
                }
            }
        }
        async void SetImageSource()
        {
            if (Element.Source != null)
            {
                if (Element.Source is UriImageSource)
                {
                    isImageInitialSet = true;


                    var uri = Element.Source.GetValue(UriImageSource.UriProperty) as Uri;

                    var bitmap = await imageDownloader.GetImageAsync(uri);

                    SetImageCorners(bitmap);
                }
                else if (Element.Source is FileImageSource)
                {
                    if ((Element.Width > 0 && Element.Height > 0) || (Element.WidthRequest > 0 && Element.HeightRequest > 0))
                    {
                        isImageInitialSet = true;

                        var source = Element.Source as FileImageSource;
                        if (source != null && source.File != null)
                        {
                            var resourceID = UIHelper.GetDrawableResource(source);
                            if (resourceID > 0)
                            {
                                Bitmap imageBitmap = ImageCache.Instance.Get(resourceID.ToString());
                                if (imageBitmap == null)
                                {
                                    var width             = BaseUIHelper.ConvertDPToPixels(Element.Width <= 0 ? Element.WidthRequest : Element.Width);
                                    var height            = BaseUIHelper.ConvertDPToPixels(Element.Height <= 0 ? Element.HeightRequest : Element.Height);
                                    BitmapWorkerTask task = new BitmapWorkerTask(imageView, width, height, ImageCache.Instance);
                                    imageView.SetImageDrawable(new AsyncDrawable(imageView.Resources, null, task));
                                    task.Execute(resourceID);
                                    task.Finished += (s, e) =>
                                                     SetImageCorners(e);
                                }
                                else
                                {
                                    SetImageCorners(imageBitmap);
                                }
                            }
                            else
                            {
                                var imageBitmap = await BitmapFactory.DecodeFileAsync(source.File);

                                SetImageCorners(imageBitmap);
                            }
                        }
                    }
                }
                else if (Element.Source is StreamImageSource)
                {
                    isImageInitialSet = true;
                    var source = Element.Source as StreamImageSource;
                    var cts    = new System.Threading.CancellationTokenSource();
                    var str    = await source.Stream(cts.Token);

                    using (var reader = new System.IO.BinaryReader(str))
                    {
                        var data   = reader.ReadBytes((int)str.Length);
                        var bitmap = await BitmapFactory.DecodeByteArrayAsync(data, 0, data.Length);

                        SetImageCorners(bitmap);
                    }
                }
            }
            else
            {
                if (Element.ImagePlaceholder == null)
                {
                    imageView.SetImageBitmap(null);
                }
            }
        }
        private async void UpdateBitmap(Image previous = null)
        {
            if (Element == null || Control == null)
            {
                return;
            }

            Bitmap      bitmap = null;
            ImageSource source = Element.Source;

            if (previous == null || !object.Equals(previous.Source, Element.Source))
            {
                SetIsLoading(true);
                ((CustomImageView)base.Control).SkipInvalidate();

                // I'm not sure where this comes from.
                //   Control.SetImageResource(17170445);

                if (BaseControl.ImagePlaceholder != null)
                {
                    var placeholder = BaseControl.ImagePlaceholder as FileImageSource;

                    var resourceID = UIHelper.GetDrawableResource(placeholder);
                    if (resourceID > 0)
                    {
                        Bitmap imageBitmap = imageCache.Get(resourceID.ToString());
                        //imageBitmap = BitmapFactory.DecodeResource(Context.Resources, resourceID);

                        if (imageBitmap == null)
                        {
                            BitmapWorkerTask task = new BitmapWorkerTask(Control, -1, -1, imageCache);
                            Control.SetImageDrawable(new AsyncDrawable(Control.Resources, null, task));
                            task.Execute(resourceID);
                            task.Finished += (s, e) =>
                            {
                                Control.SetImageBitmap(e);
                                e.Dispose();
                            };
                        }
                        else
                        {
                            Control.SetImageBitmap(imageBitmap);
                            imageBitmap.Dispose();
                        }
                    }
                }


                if (source != null)
                {
                    try
                    {
                        bitmap = await GetImageFromImageSource(source, Context);
                    }
                    catch (TaskCanceledException)
                    {
                    }
                    catch (IOException)
                    {
                    }
                    catch (NotImplementedException)
                    {
                    }
                }

                if (Element != null && object.Equals(Element.Source, source))
                {
                    if (!_isDisposed)
                    {
                        if (bitmap == null && BaseControl.ImagePlaceholder != null)
                        {
                        }
                        else
                        {
                            Control.SetImageBitmap(bitmap);
                        }

                        if (bitmap != null)
                        {
                            bitmap.Dispose();
                        }
                        SetIsLoading(false);
                        ((IVisualElementController)base.Element).NativeSizeChanged();
                    }
                }
            }
        }