Пример #1
0
        private void SetDefaultPalette()
        {
            var bitmap = BitmapDecoder.DecodeSampledBitmapFromResource(command.Resources,
                                                                       Resource.Drawable.ic_broken_image_white_48dp, new TileImageSize(100));
            var palette         = new PalettUtil();
            var tileTextPalette = new TileTextPaletteDecorator(palette, bitmap);

            currentPalette = tileTextPalette.Color;
            tileTextPalette.SetPalette(ItemView.FindViewById <RelativeLayout>(Resource.Id.relative_layout_goal_item_info_tile));
            tileTextPalette.SetPalette(ItemView.FindViewById <TextView>(Resource.Id.text_view_goal_item_date));
        }
Пример #2
0
        private void SetCropView(Uri data)
        {
            imageWrapper.Visibility         = ViewStates.Gone;
            existingImageWrapper.Visibility = ViewStates.Gone;
            cropViewWrapper.Visibility      = ViewStates.Visible;
            selectedImageUri = data;

            var imageSize = new AppBarImageSize(Resources.DisplayMetrics);
            var fallback  = BitmapDecoder.DecodeSampledBitmapFromResource(Resources,
                                                                          Resource.Drawable.ic_broken_image_white_48dp, imageSize);

            if (!string.IsNullOrEmpty(selectedImageUri?.Path))
            {
                Bitmap bitmap;
                using (var decoder = new BitmapDecoder())
                {
                    bitmap = decoder.DecodeSampledBitmapFromUri(ContentResolver, selectedImageUri, imageSize, fallback);

                    var w = bitmap.Width;

                    var scaledHeight = bitmap.Height * imageSize.Width / w;

                    if (scaledHeight < imageSize.Height)
                    {
                        var h           = bitmap.Height;
                        var scaledWidth = bitmap.Width * imageSize.Height / h;
                        bitmap = Bitmap.CreateScaledBitmap(bitmap, scaledWidth, imageSize.Height, true);
                    }
                    else
                    {
                        bitmap = Bitmap.CreateScaledBitmap(bitmap, imageSize.Width, scaledHeight, true);
                    }
                }

                cropView.SetImageBitmap(bitmap);
            }
        }