Android 2.3 gallery3d added GIF support-Overview (1)

Source: Internet
Author: User

Speaking of GIF, many Android software currently have this function, such as Sina Weibo. On the Android 2.3 platform, gallery3d is used to view images in the system. It does not play GIF images. Gallery3d is an android image browsing application made by cooliris. Due to its 3D effect, it is called gallery3d, which is also separated from its own gallery. For more information about gallery3d, see here. In my opinion, Android
Gallery3d in 2.3 is still very complex and worth studying. This time, it is only because of work reasons that it involves the tip of the iceberg. Leave this note to be noted.

Welcome to reprint, please be sure to indicate the source: http://blog.csdn.net/yihongyuelan

For GIF addition, the article is roughly divided into three parts:

(1) overview; it mainly involves the basic knowledge of gallery3d.

(2) The image display process mainly involves displaying thumbnails and large charts.

(3) code framework. Add GIF support to gallery3d to enable normal playback.

The purpose of the article is very simple. On the one hand, I will take notes for myself, and on the other hand, I will review it. In this article, gallery3d will not be expanded, mainly around the main line "adding GIF support", so many places may not be so detailed, or I have not figured out it myself, at the end of the article, I will provide some reference materials. If you are interested in the study, you can refer to and learn for yourself.

The original meaning of GIF (Graphics Interchange Format) is "image Interchange Format", which was developed by CompuServe in 1987. GIF file data is a continuous-tone lossless compression format based on LZW algorithm. Generally, the compression rate is about 50%. It does not belong to any application. The data in GIF image files is compressed and adopts a variable length compression algorithm. Another feature of the GIF format is that it can store multiple color images in a GIF file. If you read multiple image data in a file one by one and display it on the screen, to form the simplest animation. (From Baidu encyclopedia)

The Interface Generation of gallery3d is different from that of common applications. The gallery3d interface is drawn through OpenGL. The whole interface is in the same activity, such as the main interface, thumbnail interface, single image Viewing Interface, and tag interface.

Gallery3d has two overall modes: Tag mode and common mode. The tag mode is also the multiple-choice mode, including the main interface tag mode, the scaled interface matrix browsing tag mode, and the tag mode when the thumbnail interface is classified for browsing. Common modes include the main interface browsing mode, thumbnail matrix browsing mode, view interface mode, and thumbnail interface classification browsing mode. It sounds a bit difficult. Figure 1 clearly shows the basic mode in gallery3d. 1:

Figure 1

The following are the basic components of gallery3d, including:

Com. cooliris. Media. gridlayer: Grid thumbnails and Individual Image Display
Com. cooliris. Media. backgroundlayer: gallery3d background
Com. cooliris. Media. hudlayer: album display
Com. cooliris. Media. imagebutton: Image button
Com. cooliris. Media. timebar: The floating control that can be dragged in gallery3d
Com. cooliris. Media. menubar: the menu button is displayed when you click the image.
Com. cooliris. Media. popupmenu: the menu item is displayed.
Com. cooliris. Media. pathbarlayer: Display Path Control

2:

Figure 2

General workflow of gallery3d:


1. Create a cache.

Cacheservice in gallery3d will also create thumbnails for these media files. The extensive path of SD card thumbnails/mnt/sdcard/Android/data/COM. cooliris. media/, which is not saved as a thumbnail, but as a cache file. (Note: After an SD card is inserted, mediascanner scans the SD card and saves the attributes of the scanned media file to the database (data/COM. android. providers. media/databases/external-xxxxx.db), while mediascanner generates a thumbnail of the scanned media file, stored in/sdcard/dcim /. thumnails
Below, this is generated by the platform for some apps that need to use it to be called through mediastore)


2. thumbnail display.

In gallery3d, thumbnails are displayed in fixed width and height (set in gridlayer) boxes to obtain image information (cacheservice) from the database. getimagelist), and then draw the thumbnail to the canvas using OpenGL. The refresh () method in cacheservice is responsible for creating the album and placing the image in the album.


3. Large image display.

The big image is the image displayed when we click a thumbnail. The specific method is to find the image in the corresponding SD card based on the path of the image in the database, and then load the image into the cache block (cachecrc64 (item. (mflie) method to convert the path to cacheid), where the mfile is the path of the image in the SD card (saved to item from the database ), the cache block corresponding to this mfiled is set in the writeitemstocache () method (there is also a writesetstocache method ). Finally, griddrawmanager. drawfocusitems () is called to draw an image and display it on the interface.

The above process is only a small part of the gallery3d workflow. The main purpose of this article is to get a general idea of gallery3d. At the end of the article, some netizens analyzed the information and added their own tracking code to get the above conclusions. please correct me if there is any error.


Gallery3d workflow: http://www.eoeandroid.com/forum.php? MoD = viewthread & tid = 40903 & extra = & Highlight = & page = 1

Gallery3d: http://blog.sina.com.cn/s/blog_972577b301010qmj.htmlhttp://blog.csdn.net/hopesjd/article/details/7716410

Cache process: http://www.eoeandroid.com/thread-41920-1-1.html

Gallery3d source code analysis summary (recommended): http://wenku.baidu.com/view/25ecc9d87f1922791688e8fc.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.