0

I am developing an app to display total images of device in gallery of my application. Every thing is working fine but i had a performance issue with MediaStore.Images.Thumbnails.getThumbnail() method. Usually it is returning bitmap a bit fast but when i am dumping images from PC to android device it is taking lot of time to return the bitmap. Please help how to optimize this. Is there a better way to create a thumbnail instead of MediaStore.Images.Thumbnails.getThumbnail() method??

Thanks, Ram.

ram
  • 3,487
  • 10
  • 33
  • 47

1 Answers1

2

getThumbnail will create a thumbnail .jpg on your device and return you the decoded version of that. If you put new images on your device it will take longer because a) the mediascanner has to scan all the new files and b) that thumbnail image has to be created first. Thumbnail creation from big images can take some time.

You can create the image yourself if you want but I doubt you can get thumbnails faster unless you have special optimized native code.

zapl
  • 63,179
  • 10
  • 123
  • 154
  • Is there a way to force the media scanner to create thumbnail?? or is there any special optimized native code available in net? – ram Apr 16 '12 at 14:59
  • By calling getThumbnail you are already forcing the media scanner to create a thumbnail for you. – Renard Apr 16 '12 at 14:59
  • Is this some thing related to me?? http://stackoverflow.com/questions/5107823/force-scan-files-after-taking-photo – ram Apr 16 '12 at 15:00
  • well you can trigger the creation of thumbails also by inserting the picture via the ContenProvider. But still creating a thumbnail from a large bitmap takes time. So the answer from @zapl is correct. If you want to get thumbs faster you need to create your own thumbnails. – Renard Apr 16 '12 at 15:05