Добавляю в ImageView
картинку из библиотеки. И так как как фото много весит это грузит приложение.
Как снизить качество фото для отображаемого View-элемента? Есть наработки у кого то?
Нашел в туториалах такое решение и не могу понять какие компоненты использовать.
Что нужно для полей : getResources()
, R.id.myimage
,reqHeight
, reqWidth
.
В тоториале говорится:
getResources() The resources object containing the image data
R.id.myimage The resource id of the image data
Но что бы это могло значить? E меня есть только url картинки и View.
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(getResources(), R.id.myimage, options);
int imageHeight = options.outHeight;
int imageWidth = options.outWidth;
String imageType = options.outMimeType;
// Raw height and width of image
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
final int halfHeight = height / 2;
final int halfWidth = width / 2;
// Calculate the largest inSampleSize value that is a power of 2 and keeps both
// height and width larger than the requested height and width.
while ((halfHeight / inSampleSize) > reqHeight
&& (halfWidth / inSampleSize) > reqWidth) {
inSampleSize *= 2;
}
}
ContentProvider
тоже.беру картинку с библиотеки на телефоне