[這篇比較全而且正確]Android製作啟動LOGO

來源:互聯網
上載者:User

一.去除embedded linux 的開機游標:

 在核心的目前的目錄進入到drivers/video/console/fbcon.c 檔案
 將static void fb_flashcursor(void *private)   和 static void fbcon_cursor(struct vc_data *vc, int mode) 裡的內容注釋掉,使之變成空函數


二 、 Android 開機會出現3個畫面: 
1. Linux 系統啟動,出現Linux小企鵝畫面(reboot)(Android 1.5及以上版本已經取消載入圖片); 
2. Android平台啟動初始化,出現"A N D R I O D"文字字樣畫面; 
3. Android平台圖形系統啟動,出現含閃動的ANDROID字樣的動畫圖片(start)。

4、splash(LK裡跑的logo)


1、開機圖片(Linux小企鵝) (Android 1.5及以上版本已經取消載入圖片); 
Linux Kernel引導啟動後,載入該圖片。 
logo.c中定義nologo,在fb_find_logo(int depth)函數中根據nologo的值判斷是否需要載入相應圖片。 
代碼如下: 
static int nologo; 
module_param(nologo, bool, 0); 
MODULE_PARM_DESC(nologo, "Disables startup logo"); 
/* logo's are marked __initdata. Use __init_refok to tell 
* modpost that it is intended that this function uses data 
* marked __initdata. 
*/ 
const struct linux_logo * __init_refok fb_find_logo(int depth) 
{ 
const struct linux_logo *logo = NULL; 
if (nologo) 
return NULL; 
        ...... 
} 
相關代碼: 
/kernel/drivers/video/fbmem.c 
/kernel/drivers/video/logo/logo.c 
/kernel/drivers/video/logo/Kconfig 
/kernel/include/linux/linux_logo.h

     (1)讓核心支援啟動LOGO

        在核心目錄中 make menuconfig

        Device Drivers ---->   Graphics support ---->

        選中 Bootup logo ----> Standard 224-color Linux logo

     (2) 製作一張啟動LOGO的PNG格式的圖片logo_linux_clut224.png

     (3)sudo apt-get install netpbm


          #pngtopnm logo_linux_clut224.png>logo_linux.pnm

          #pnmquant 224 logo_linux.pnm > logo_linux_224.pnm

          #pnmtoplainpnm logo_linux_224.pnm>logo_linux_clut224.ppm 

      (4)將LOGO檔案放入核心中

           拷貝到製作好的LOGO檔案到  /drivers/video/logo 檔案夾

           替換  logo_linux_clut224.ppm 檔案

      (5)重新編譯核心

 

2、開機文字("A N D R I O D") 
     Android 系統啟動後,init.c中main()調用load_565rle_image()函數讀取/initlogo.rle(一張565 rle壓縮的位元影像),如果讀取成 功,     則 在/dev/graphics/fb0顯示Logo圖片;如果讀取失敗,則將/dev/tty0設為TEXT模式, 並開啟/dev/tty0,輸出文本“A N D R I O D”字樣。 
定義載入圖片檔案名稱 
#define INIT_IMAGE_FILE "/initlogo.rle" 
int load_565rle_image( char *file_name ); 
#endif 
init.c中main()載入/initlogo.rle檔案。 


if( load_565rle_image(INIT_IMAGE_FILE) ) {//載入initlogo.rle檔案
fd = open("/dev/tty0", O_WRONLY);//將/dev/tty0設為text模式
if (fd >= 0) {
const char *msg;
msg = "/n"
"/n"
"/n"
"/n"
"/n"
"/n"
"/n" // console is 40 cols x 30 lines
"/n"
"/n"
"/n"
"/n"
"/n"
"/n"
"/n"
" A N D R O I D ";
write(fd, msg, strlen(msg));
close(fd);
}
}
相關代碼:
/system/core/init/init.c

/system/core/init/init.h
/system/core/init/init.rc
/system/core/init/logo.c
*.rle檔案的製作步驟:
a. 使用GIMP或者Advanced Batch Converter軟體,將圖象轉換為RAW格式;
b. 使用android內建的rgb2565工具,將RAW格式檔案轉換為RLE格式(如:rgb2565 -rle < initlogo.raw > initlogo.rle)。

3、開機動畫(閃動的ANDROID字樣的動畫圖片) 
Android 1.5版本:Android的系統登入動畫類似於Windows系統的捲軸,是由前景和背景兩張PNG圖片組成,這兩張圖片存在於手機或模擬器 /system/framework/framework-res.apk檔案當中,對應原檔案位於/frameworks/base/core/res /assets/images/。前景圖片(android-logo-mask.png)上的Android文字部分鏤空,背景圖片(android- logo-shine.png)則是簡單的紋理。系統登入時,前景圖片在最上層顯示,程式碼(BootAnimation.android())控制背 景圖片連續滾動,透過前景圖片文字鏤空部分滾動顯示背景材質,從而實現動畫效果。 
相關代碼: 
/frameworks/base/libs/surfaceflinger/BootAnimation.h 
/frameworks/base/libs/surfaceflinger/BootAnimation.cpp 
/frameworks/base/core/res/assets/images/android-logo-mask.png  Android預設的前景圖片,文字部分鏤空,大小256×64 
/frameworks/base/core/res/assets/images/android-logo-shine.png Android預設的背景圖片,有動感效果,大小512×64

Android 1.6及以上版本: 
init.c解析init.rc(其中定義服 務:“service bootanim /system/bin/bootanimation”),bootanim服務由SurfaceFlinger.readyToRun() (property_set("ctl.start", "bootanim");)執行開機動畫、bootFinished()(property_set("ctl.stop", "bootanim");)執行停止開機動畫。 
BootAnimation.h和BootAnimation.cpp檔案放到了 /frameworks/base/cmds/bootanimation目錄下了,增加了一個入口檔案bootanimation_main.cpp。 Android.mk檔案中可以看到,將開機動畫從原來的SurfaceFlinger裡提取出來了,產生可執行檔:bootanimation。 Android.mk代碼如下: 
//=============Android.mk====================== 
LOCAL_PATH:= $(call my-dir) 
include $(CLEAR_VARS) 
LOCAL_SRC_FILES:= / 
    bootanimation_main.cpp / 
    BootAnimation.cpp 
# need "-lrt" on Linux simulator to pick up clock_gettime 
ifeq ($(TARGET_SIMULATOR),true) 
    ifeq ($(HOST_OS),linux) 
        LOCAL_LDLIBS += -lrt 
    endif 
endif 
LOCAL_SHARED_LIBRARIES := / 
    libcutils / 
    libutils / 
    libui / 
    libcorecg / 
    libsgl / 
    libEGL / 
    libGLESv1_CM / 
    libmedia    
LOCAL_C_INCLUDES := / 
    $(call include-path-for, corecg graphics) 
LOCAL_MODULE:= bootanimation 
include $(BUILD_EXECUTABLE) 
//========================================== 
(1)adb shell後,可以直接運行“bootanimation”來重新看開機動畫,它會一直處於動畫狀態,而不會停止。 
(2)adb shell後,命令“setprop ctl.start bootanim”執行開機動畫;命令“getprop ctl.start bootanim”停止開機動畫。這兩句命令分別對應SurfaceFlinger.cpp的兩句語 句:property_set("ctl.start", "bootanim");和property_set("ctl.stop", "bootanim"); 
相關檔案: 
/frameworks/base/cmds/bootanimation/BootAnimation.h 
/frameworks/base/cmds/bootanimation/BootAnimation.cpp 
/frameworks/base/cmds/bootanimation/bootanimation_main.cpp 
/system/core/init/init.c 
/system/core/rootdir/init.rc

4、splash(LK裡跑的logo)

準備splash.png圖,最終產生splash.raw565

1、convert splash.png -depth 8 rgb:splash.raw

2、rgb2565 < splash.raw > splash.raw565

相關code如下:

aboot.c

lcdc.c

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.