Get a thumbnail

All your problems with Audio, Video and Images.

Get a thumbnail

Postby Bichehype » Wed Mar 03, 2010 10:07 pm

Hey !

I'm trying to show a gallery with many pictures. I resize every bitmap : this process is toooo slow !
So, I found the class MediaStore.Images.Thumbnail but didn't understood how it works.

I'm working with API Level 3 : getThumbnail isn't available.

The question is : How to get a MICRO_KIND (96x96) picture in a bitmap?
Any ideas?

Thanks

BicheHype
Bichehype
Freshman
Freshman
 
Posts: 3
Joined: Sat Feb 20, 2010 11:28 pm

Top

Postby mathias.lin » Tue Mar 09, 2010 3:11 pm

see Greg Zimmers comment on:
from http://stackoverflow.com/questions/1334 ... thumbnails
(but don't know if it works for API Level 3 already)
User avatar
mathias.lin
Experienced Developer
Experienced Developer
 
Posts: 60
Joined: Tue Aug 11, 2009 4:21 am
Location: Guangzhou, China

Postby mathias.lin » Tue Mar 09, 2010 3:15 pm

An additional question regarding video thumbnails:

How to get a thumbnail of a video that's stored on the SD card, not under resources? Or how to assign an/get the id of it? Does it even have one?

For the getThumbnail method, I'd need to pass the video id as parameter:
MediaStore.Video.Thumbnails.getThumbnail(crThumb, id, MediaStore.Video.Thumbnails.MICRO_KIND, options);
User avatar
mathias.lin
Experienced Developer
Experienced Developer
 
Posts: 60
Joined: Tue Aug 11, 2009 4:21 am
Location: Guangzhou, China

Postby pskink » Tue Mar 09, 2010 4:01 pm

mathias.lin wrote:An additional question regarding video thumbnails:

How to get a thumbnail of a video that's stored on the SD card, not under resources? Or how to assign an/get the id of it? Does it even have one?

For the getThumbnail method, I'd need to pass the video id as parameter:
MediaStore.Video.Thumbnails.getThumbnail(crThumb, id, MediaStore.Video.Thumbnails.MICRO_KIND, options);


hi Mathias,

it's poorly documented, but my common sense tells me origId is not something similar to R class and its IDs.

i think its some kind of id assigned by MediaStore/MediaScanner

i didn't try it but it may be VideoColumns.MINI_THUMB_MAGIC

btw the same id is used to cancel any pending getThumbnail reaquest

after all raw files under res/raw folder are limited to afaik 1 MB and who uld like to see video that short?

greets
pskink
pskink
Master Developer
Master Developer
 
Posts: 719
Joined: Mon Nov 24, 2008 3:49 pm

Re: Get a thumbnail

Postby senormoll » Tue Mar 09, 2010 4:31 pm

Bichehype wrote:Hey !

I'm trying to show a gallery with many pictures. I resize every bitmap : this process is toooo slow !
So, I found the class MediaStore.Images.Thumbnail but didn't understood how it works.

I'm working with API Level 3 : getThumbnail isn't available.

The question is : How to get a MICRO_KIND (96x96) picture in a bitmap?
Any ideas?

Thanks

BicheHype


Since your thread was hijacked a little, I'll help you with image thumbnails lol. MediaStore is a database that Android keeps with information about every piece of media that you put on your phone's storage. To access its data, you use a cursor to query the database. Try googling cursors and databases if you've never done this, and check out this article:
Gallery Tutorial
senormoll
Developer
Developer
 
Posts: 29
Joined: Tue Feb 23, 2010 2:50 am

Postby pskink » Tue Mar 09, 2010 10:11 pm

mathias.lin wrote:An additional question regarding video thumbnails:

How to get a thumbnail of a video that's stored on the SD card, not under resources? Or how to assign an/get the id of it? Does it even have one?

For the getThumbnail method, I'd need to pass the video id as parameter:
MediaStore.Video.Thumbnails.getThumbnail(crThumb, id, MediaStore.Video.Thumbnails.MICRO_KIND, options);


just tested it

origid (the 2nd param in getThumbnail()) is just BaseColumns._ID field when you query MediaStore.Video.Media.EXTERNAL_CONTENT_URI

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. ContentResolver cr = getContentResolver();
  3.  
  4. String[] proj = {
  5.  
  6.                 BaseColumns._ID
  7.  
  8. };
  9.  
  10. Cursor c = cr.query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, proj, null, null, null);
  11.  
  12. if (c.moveToNext()) {
  13.  
  14.         int id = c.getInt(0);
  15.  
  16.         Bitmap b = MediaStore.Video.Thumbnails.getThumbnail(cr, id, MediaStore.Video.Thumbnails.MINI_KIND, null);
  17.  
  18.         Log.d(TAG, "onCreate bitmap " + b);
  19.  
  20.         ImageView iv = (ImageView) findViewById(R.id.thumbnail);
  21.  
  22.         iv.setImageBitmap(b);
  23.  
  24. }
  25.  
  26. c.close();
  27.  
  28.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


greets
pskink
pskink
Master Developer
Master Developer
 
Posts: 719
Joined: Mon Nov 24, 2008 3:49 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 9 guests