Obviously this is an expensive/time-consuming operation. Any way to improve this?
Bitmap bm = BitmapFactory.decodeStream((InputStream) new URL(
someUrl).getContent());
I’m guessing there’s really no way to avoid this relatively intense operation, but wanted to see if anyone had any tweaks they could recommend (aside from caching the actual bitmap, which for whatever reasons simply isn’t relevant here)
If you don’t need the full resolution you can have it only read ever nth pixel, where n is a power of 2. You do this by setting
inSampleSizeon an Options object which you pass toBitmapFactory.decodeFile. You can find the sample size by just reading the meta-data from the file in a first pass by settinginJustDecodeBoundson theOptionsobject. Aside from that – no, I don’t think there’s an easy way to make to go any faster than it already does.Edit, example: