android - Best way to fetch and resize bitmap from phone storage -


it seems there few different ways bitmap storage on phone.

i'm reading data images using mediastore query , save both path , imageid in memory. later if want upload small thumbnail of image can either:

1) query mediastore micro/mini kind of thumbnail based on image id, create scaled bitmap fit exact needs (if micro/mini not correct size)

bitmap bm = mediastore.images.thumbnails.getthumbnail(context.getcontentresolver(),     imageid, mediastore.images.thumbnails.mini_kind, null); bitmap.createscaledbitmap(bm, (int)newwidth, (int)newheight, true); 

or

2) fetch bitmap file location , create scaled bitmap that

bitmap bitmap = bitmapfactory.decodefile(url); bitmap.createscaledbitmap(bitmap, (int)newwidth, (int)newheight, true); 

i doing #1 because figured thumbnail generation quick mediastore make createscaledbitmap process finish quicker rather creating scaled bitmap fullsize image. there best way or difference negligible?

i'm not expert, think difference between 2 negligible, considering either way you're creating scaled image. seem difference time take scale thumbnail versus scale bitmap, , either way think you're talking nanoseconds.

honestly, seem want use #1 memory use, rather loading full size image , down sampling, you're loading thumbnail , sizing if necessary.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -