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?