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

Thumbnail not working with DecodeFile... look code

$
0
0
                public static int CalculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight)
            {
        // Raw height and width of image
        var height = (float) options.OutHeight;
        var width = (float) options.OutWidth;
                var inSampleSize = 1D;
            if (height > reqHeight || width > reqWidth)
            {
                inSampleSize = width > height
                    ? height/reqHeight
                        : width/reqWidth;
            }
            return (int) inSampleSize;
        }

        public static Bitmap DecodeSampledBitmapFromResource(string path, int reqWidth, int reqHeight)
        {
            // First decode with inJustDecodeBounds=true to check dimensions
            var options = new BitmapFactory.Options {InJustDecodeBounds = true};
            BitmapFactory.DecodeFile(path);
            // Calculate inSampleSize
            options.InSampleSize = CalculateInSampleSize(options, reqWidth, reqHeight);
            // Decode bitmap with inSampleSize set
            options.InJustDecodeBounds = false;
            return BitmapFactory.DecodeFile(path);

        }

and then im doing

using (var bmp = DecodeSampledBitmapFromResource(path+"/"+listaFotos[pagina*10], 5, 5))
{
    //Console.WriteLine(caminho+listaFotos[pagina*10]);
    imagem1.SetImageBitmap(bmp);
}

But im getting an image in the normal size that is fucking my memory the same way as without using this... Any ideia?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



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