Gallery概述

原文地址:http://letsgoustc.spaces.live.com/blog/cns!89AD27DFB5E249BA!492.entry?_c=BlogPart

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.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值