Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15531869
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类:

2008-12-05 11:36:01

[First written by Steve Guo, please keep the mark if forwarding.]

If the “picture” icon is clicked on Launcher activity, it brings up GalleryPicker activity. The GalleryPicker activity calls ImageManager to query folders which contains image files from MediaProvider. (When reading source code, remember that the gallery and bucket symbol equals to folder.) For each folder, it generates a 142*142 mini thumbnail to represent the folder according to the number of images in the folder. For a single image, that image draws over the whole folder. For four or more images, only the first four photos are selected to make the image.

If no or only one image folders, it automatically launches ImageGallery2 activity to view the folder.

If more than one image folders, it uses GridView to display these auto-generated 142*142 mini thumbnails, when user clicks on any item, it also launches ImageGallery2 activity to view the corresponding folder.

 

ImageGallery2 creates a background thread to call ImageManager to retrieve a 96*96(defined by MINI_THUMB_TARGET_SIZE) mini thumbnail for any image in the folder. ImageManager first queries whether the mini thumbnail has generated before from MediaProver. If not, it will generate one and update to MediaProvider. The generated method has a special performance consideration: If original image file contains thumbnail picture, it will be used(For some JPEG EXIF file, it may have). All these thumbnails will be saved into one random file in the folder “$(EXTERNAL_STORAGE)/dcim/.thumbnails” by ImageManager. One thumbnail occupies exactly 10000 bytes(defined by sBytesPerMiniThumb) in the file. The file name’s format is “.thumbdata3-XXX”. 3 is MINI_THUMB_DATA_FILE_VERSION. XXX is some kind of hash code corresponding to a folder.

ImageGallery2 implements an important feature just like Windows: It tracks the current position and only fetches these mini thumbnails can be seen at the current position. Other unseen pictures won’t be fetched. So that user can quickly see mini thumbnails when he scrolls down or up. The feature is implemented in GridViewSpecial and ImageBlockManager.

 

If a mini thumbnail icon is clicked in ImageGallery2, the ViewImage activity will be launched to view the corresponding image. Here's the loading strategy.  For any given image, load the thumbnail into memory and post a callback to display the resulting bitmap. Then proceed to load the full image bitmap. All these are implemented in ImageGetter. The thumbnail also is generated only once, as long as generated by ImageManager, it will be saved into “$(EXTERNAL_STORAGE)/dcim/.thumbnails/YYY.jpg”. YYY is some kind of hash code corresponding to an image file. ImageManager also updates to MediaProvider for history use. The maximum thumbnail size is 320*320(define by THUMBNAIL_TARGET_SIZE).

 

For sliding show feature, it’s implemented in SlideShow activity which will be started from ImageGallery2 and GalleryPicker as the result of one menu item click.

阅读(1846) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~