Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Help with Scalling Image

$
0
0

Hello. I have a problem with the bitmap merge. Where did I make a mistake? The image simply does not display in ImageView.

            ShowExample.Click += (e, o) =>
            {
            LayoutInflater inflater = LayoutInflater.From(this);
            View mview = inflater.Inflate(Resource.Layout.example, null);
            Android.App.AlertDialog.Builder alertDialogBulider = new Android.App.AlertDialog.Builder(this);
            alertDialogBulider.SetView(mview);

            var imageView = mview.FindViewById<ImageView>(Resource.Id.imageView1);
            //imageView.SetImageResource(Resource.Drawable.ExampleInterpolationPic);

            string appPackageName = Application.Context.PackageName;

            var path = Android.Net.Uri.Parse("android.resource://" + appPackageName + "/" + Resource.Drawable.ExampleInterpolationPic).Path;

            File imgFile = new File(path);
            if (imgFile.Exists())
            {
                BitmapFactory.Options i = new BitmapFactory.Options();
                i.InSampleSize = 4; //This example will make image size 1/4 of it's normal, and 1/16 the number of pixels.
                Bitmap bitmap = BitmapFactory.DecodeFile(imgFile.AbsolutePath, i);
                imageView.SetImageBitmap(bitmap);
            }

            alertDialogBulider.SetCancelable(false).SetNegativeButton("Anuluj", delegate
            {
                alertDialogBulider.Dispose();
            });

            Android.App.AlertDialog alertDialogAndroid = alertDialogBulider.Create();
            alertDialogAndroid.Show();
            };

Is the error occurring in BitmapFactory metod?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>