Android logo: kernel and Android boot Animation

Source: Internet
Author: User
Tags bmp image imagemagick

Keywords: Android
Boot logo boot animation initlogo. RLE bootanimation desc.txt

Platform information:
Kernel: linux2.6/linux3.0
System: Android/android
Platform: s5pv310 (samsungexynos4210/4412)

Author: xubin341719 (You are welcome to reprint it. Please note the author)

Android logo, which has been changed a lot at work, is also relatively simple. Different companies and products of different models have different boot logos.

We usually use two types of visual boot logos: static and animated. In fact, in the process of Logo implementation, there are four images: (1) uboot display; (2) kernel display logo_linux_clut244.ppm; (3) the first Android intilogo. rle; (4), Android second, bootanimation. The first three images are generally the same, and (4) are animated. The startup process is as follows.

This article focuses on how to generate the files to be used, and the program will not go into depth. This piece of code is not small, and there is no need for any changes. The uboot logo will affect the boot speed. We didn't do this either. The uboot startup speed is still relatively fast, and the black screen for several seconds is acceptable. The following describes the kernel logo.

I. kernel logo

1. Make menuconfig in the kernel directory

Device Drivers ----> graphics support ----> bootup logo ----> standard 224-color Linux logo

Save the boot logo image as BMP or PNG: for example, linux.pngw.linux.bmp. Convert the image to the PPM format through the Linux tool. Replace: Driver/Video/logo/logo_linux_clut244.ppm

The following command needs to install the netpbm Toolkit
If no: sudo apt-Get install netpbm

My experiments, including scripts, can be downloaded here: Android logo script

(1) For images in PNG format, run the following command:

# Pngtopnm linuxlogo.png> linuxlogo. PNM // generate ppm # pnmquant 224 linuxlogo. PNM> linuxlogo224.pnm // convert to 224 colors # pnmtoplainpnm linuxlogo224.pnm> convert to ASCII format

You can write the preceding command as a script to make it easier to use:

Kernellogo_png.sh

Pngtopnm $1> linuxlogo. PNM // $1 is the parameter, so you do not need to change the image name each time. The next step is the execution process pnmquant 224 linuxlogo. PNM> linuxlogo224.pnmpnmtoplainpnm linuxlogo224.pnm> logo_linux_clut224.ppm # generate unnecessary file Rm-RF during deletion. /linuxlogo. PNM. /linuxlogo224.pnm Rm-RF. /linuxlogo. PNM. /linuxlogo224.pnm

For example, ① cat./kenrellogo_png.sh to view the script content, as explained below

②./Kenrellogo_png.sh run the script

③ Ls: Check the generated logo_linux_clut224.ppm.

(1). BMP Images

The script is kenrellogo_bmp .sh.

Convert $1 linuxlogo.png // convert the BMP image to PNG format. The following process is the same as that of the PNG format: pngtopnm linuxlogo.png> linuxlogo. pnmpnmquant 224 linuxlogo. PNM> linuxlogo224.pnmpnmtoplainpnm linuxlogo224.pnm> logo_linux_clut224.ppmrm-RF. /linuxlogo. PNM. /linuxlogo224.pnm. /linuxlogo.png

Copy logo_linux_clut224.ppm to the created logo file to the/Drivers/Video/logo folder to replace the logo_linux_clut224.ppm file, delete the scripts in the folder, compile the scripts, and you will see the modified images.

Ii. Android logo

1. Android's first logo

(1agfind an image in .png format and convert the raw format using the convert command provided by ImageMagick in Linux. The command is:

convert -depth 8 android_logo.pngrgb:android_logo.raw

(2), need to use Android compiled rgb2565 tool, in the android/out/host/linux-x86/bin directory (Android is the current source code directory), the conversion command is as follows:

rgb2565 -rle < android_logo.raw >initlogo.rle

Note: The imgagemagick tool is installed by default in ubuntu10.04. If the current system is not installed, run the following command to install it:

Sudo apt-getinstall ImageMagick

For convenience, we copied the BIND file rgb2565 to our animation folder. A script is also written above:

Android_rle.sh

Convert-depth 8 $1 RGB: logo. raw // convert to raw file rgb2565-RLE <logo. raw> initlogo. rle // generate the RLE file we want, note: rbg2565 copied in the android/out/host/linux-x86/bin directory.

Start the image to be displayed, that is, the initlogo. RLE, note that the file name must be this. If you want to change the file name, you need to modify Android/system/CORE/init. macro in H:

#define INIT_IMAGE_FILE "/initlogo.rle"

Put it in the corresponding directory.

1,Android second picture (animation)
(1) boot animation file:/system/Media/bootanimation.zip is a standard ZIP file, but select storage when setting the compression ratio.

(2) packaging with commands in Linux:

Zip-r-X-zstore ../bootanimation part */*. PNG desc.txt

(3) Structure of the compressed package:

① The PNG Image shown in the part folder

The content in includesc.txt should be analyzed and the image artist should write some values here for normal display. Check the content.

400 800 18 P 1 0 part0 #400 800 indicates the image resolution 400*800 #18 indicates the number of images displayed per second, that is, 18fps/s # P indicates defining a part. # The first number after P is the number of replay times. If this number is 0, it will be played in an infinite loop # The second number after P is the number of delayed frames before the next part of playback # The string defines the file loading path

Additional information: initlogo. RLE:

Androidinitlogo. RLE

Keywords: androidinitlogo. RLE
Boot Screen

Platform information:
Kernel: linux2.6/linux3.0
System: Android/android4.0.3
Platform: Samsung exynos 4210, exynos 4412, and exynos 5250

Author: xubin341719 (You are welcome to reprint it. Please note the author)

Download the corresponding code: initlogo 32bpp change code

The Samsung platform is the best. The initlogo. RLE image is not normal. You need to modify some code. Why are they not perfect when they are doing BSP ?? If you complain, you still have to do things.

Our phenomenon is: when loading initlogo. RLE, two small pictures are displayed (originally designed as one). How can we analyze the code below.

I. initlogo. RLE is implemented in the lele_init_action function.

Path: Android/system/CORE/init. c

Static int console_init_action (INT nargs, char ** ARGs ){.................. If (load_565rle_image (init_image_file) {// 1. The second logo is displayed. FD = open ("/dev/tty0", o_wronly); If (FD> = 0) {// 2. If not, "android" is displayed; const char * MSG; MSG = "\ n" "\ n" \ n "// console is 40 Cols x 30 lines" \ n "" a n d r o I d "; write (FD, MSG, strlen (MSG); close (FD) ;}} return 0 ;}

1. display the second logo;

Load_565rle_image (init_image_file ):

(1), init_image_file

Defined in Android/system/CORE/init. H, the path of the image generated is specified;

#define INIT_IMAGE_FILE"/initlogo.rle"int load_565rle_image( char *file_name );

(2) Implementation of the load_565rle_image function involves a data format issue, such as 16bpp, 32bpp ...... If not compared, the screen is displayed.

2. If not, "android" is displayed;

If load_565rle_image fails, only the android text is displayed;

Ii. Next we will focus on the load_565rle_image function.

Android/system/CORE/init/logo. c

Int load_565rle_image (char * fN) {struct FB; struct stat s; unsigned short * data, * PTR; unsigned count, Max; int FD; If (vt_set_mode (1 )) // 1. This part of FB operations will not be detailed here; Return-1; FD = open (FN, o_rdonly); If (FD <0) {error ("cannot open '% s' \ n", FN); goto fail_restore_text;} If (fstat (FD, & S) <0) {goto fail_close_file ;} data = MMAP (0, S. st_size, prot_read, map_shared, FD, 0); If (Data = map_failed) goto fail_close_file; If (fb_open (& FB) goto fail_unmap_data; max = fb_width (& FB) * fb_height (& FB); // 2. obtain the maximum cache space on the screen. PTR = data; Count = S. st_size; If (fb_bpp (& FB) = 16) {// 3. 16bpp uint16_t * bits = (uint16_t *) FB. BITs; while (count> 3) {unsigned n = PTR [0]; If (n> MAX) break; android_memset16 (bits, PTR [1], n <1 ); bits + = N; max-= N; PTR + = 2; count-= 4 ;}} else if (fb_bpp (& FB) = 32) {// 4, 32bpp uint32_t * bits = FB. BITs; // The while (count> 3) added to the 32bpp code {unsigned n = PTR [0]; If (n> MAX) break; uint32_t data32 = (0xff <24) | (PTR [1]> 11) & 0x1f) <19) | (PTR [1]> 5) & 0x3f) <10) | (PTR [1] & 0x1f) <3); android_memset32 (bits, data32, n <2); bits + = N; max-= N; PTR + = 2; count-= 4 ;}} munmap (data, S. st_size); // 5. The display is complete. The memory is released. fb_update (& FB); fb_close (& FB); close (FD); unlink (FN); Return 0; fail_unmap_data: munmap (data, S. st_size); fail_close_file: Close (FD); fail_restore_text: vt_set_mode (0); Return-1 ;}

1. This part of FB operations will not be detailed here;

2. obtain the maximum cache space on the screen;

   max = fb_width(&fb) * fb_height(&fb);

Obtain screen parameters;

3. 16bpp;

    if (fb_bpp(&fb) == 16) {        uint16_t *bits = (uint16_t*) fb.bits;        while (count > 3) {            unsigned n = ptr[0];            if (n > max)                break;            android_memset16(bits, ptr[1], n << 1);            bits += n;            max -= n;            ptr += 2;            count -= 4;        }

4. 32bpp;

if (fb_bpp(&fb) == 32) {        uint32_t *bits = fb.bits;        while (count > 3) {            unsigned n = ptr[0];            if (n > max)                break;            uint32_t data32 = (0xff << 24) | (((ptr[1]>>11)&0x1f)<<19) | (((ptr[1]>>5)&0x3f)<<10) | (( ptr[1]&0x1f)<<3);            android_memset32(bits, data32, n << 2);            bits += n;            max -= n;            ptr += 2;            count -= 4;        }

5. The display is complete and the memory is released;

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.