I am following the android developer tutorials on displaying bitmap's efficiently and I'm trying to read a bitmap's dimensions and type.
This is the code I have for reading the bitmap:
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
image = BitmapFactory.decodeResource(context.getResources(), R.id.myimage, options);
imageHeight = options.outHeight;
imageWidth = options.outWidth;
imageType = options.outMimeType;
My results for imageHeight, imageWidth both seem to be 0 and the imageType is null.
The image is of bitmap format.
My onCreate method is
ImageView imgView = (ImageView) findViewById(R.id.myimage);
Drawable draw = getResources().getDrawable(R.drawable.bmp_login_screen);
imgView.setImageDrawable(draw);
TextView textView = (TextView) findViewById(R.id.text_view);
ReadBitmapDimen dimensions = new ReadBitmapDimen(getApplicationContext());
textView.setText(" Dimensions for userlogin image: outHeight = " + String.valueOf(dimensions.imageHeight));
Thanks!
Change this line - image = BitmapFactory.decodeResource(context.getResources(), R.id.myimage, options);
to
image = BitmapFactory.decodeResource(context.getResources(), R.drawable.bmp_login_screen, options);