Reputation: 4480
I am learning how to use Bitmap to scale down images instead of having them crash the app. I am following the developer page for android at http://developer.android.com/training/displaying-bitmaps/load-bitmap.html. I have a couple of questions about the code.
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;
For the code above it creates a new bitmapFactory and decodes the widget. Why use R.id.myimage over R.drawable.image? I am assuming that R.id.myimage refers to a image view while R.drawable.image I added and it directly refers to the image I want rescaled. Finally what does outMimeType refer too?
Upvotes: 0
Views: 66
Reputation: 2117
You know, I'm pretty sure that's a mistake. The resource you want is indeed a drawable, referenced by R.drawable.image
.
The options.outMimetype
just tells you what the mimetype of the decoded resource is (a PNG, a JPEG, etc.), if that information is available.
Upvotes: 1