1
I developed an application where I download a JPEG image (size 184x274) from a URL. When downloading from the URL I get a bitmap of 184x274 pixels, that is to say it has the same dimension as the original image. If my original image is in the res/drawable-mdpi folder and using the following code:
Bitmap imageFromRes;
imageFromRes = BitmapFactory.decodeResource(getResources(), R.drawable.imagem);
int hr = imageFromRes.getHeight();
int wr = imageFromRes.getWidth();
get hr = 552 and Wr=822, that is to say a 552x822 dimension and the image is 3 times larger than the original image. Why does this happen? Thank you
It would be possible to inform the URL of the image you are testing?
– André Ribeiro
@Andréribeiro The URL used is this: http://alunos.deec.uc.pt/~a2008112913/image%20lida.jpg
– MarcoAF
This image is 274x184. It’s the original?
– André Ribeiro
@Andréribeiro No, I put the original image in the res folder and got the width and height of the image using the following code: imageFromRes = Bitmapfactory.decodeResource(getResources(), R.drawable.imagem); int hr = imageFromRes.getHeight(); int Wr = imageFromRes.getWidth(); and I got a height of 552 and a width of 822... so I think these values are the correct ones of the original image. Thank you
– MarcoAF
I don’t understand. This link you sent is from the image generated or of original? I wanted to see the original image so I could test.
– André Ribeiro
I downloaded the bitmap from the image URL, which is the same image I put in the res folder of my application. However in the bitmap obtained by download from the URL I got a dimension of 184x274 and in the bitmap obtained from the res folder using the code I put in the previous comment I got 552x822. The image in the res folder is the same image that is in this URL. Sorry if I didn’t make myself clear, I hope it is now explicit :) Thank you
– MarcoAF
Mark, edit your question and add this information. As it is written there it seems that your problem is quite another.
– André Ribeiro
I’m sorry, I’ve already been able to confirm that the original image is 184x274! However using the code to load the bitmap, from the res folder the image is 552x822. But I don’t know why. Thanks I will edit.
– MarcoAF