高通平台开机logo制作

本文将介绍LK的logo制作方法,以及代码上的修改。

1、基础简介

LK的logo分为两种

1.1 、当图片内容比较小的时候,将图片的数据放入.h 文件

1.2、当图片内容比较大的时候,将图片的数据做成镜像文件,输入splash 分区

2、 LK Logo by splash

如何制作splash 分区的镜像文件

2.1、首先需要一张符合手机分辨率的图片。

首先利用convert工具,转换图片成.raw格式。 Eg: convert -depth 8 splash.png rgb:splash.raw,图片要是png格式

2.2、利用image_kit 将文件转换成.img 文件
./image_kit 1080 1920 splash.raw,输入图片分辨率会自动的生成splash.img 文件,这个工具会将图片的宽高写入镜像文件

image_kit 的工具制作见附录代码

2.3、 如何将镜像文件刷入splash 分区
将splash.img 文件内容写入到dev/block/platform/msm_sdcc.1/byname/splash 就可以。

见附录代码

2.4、LK splash 在代码中修改
在bootable/bootloader/lk/platform/msm_shared/partition_parser.c 中
char *ext3_partitions[] =
- { "system", "userdata", "persist", "cache", "tombstones" };
+ { "splash", "system", "userdata", "persist", "cache", "tombstones" };
char *vfat_partitions[] = { "modem", "mdm", "NONE" };
添加splash分区的名字
在bootable/bootloader/lk/platform/msm_shared/partition_parser.c 中
mbr_fill_name 会将 ext3_partitions 中分区的名字存入partition_ent->name中。

在bootable/bootloader/lk/app/aboot/aboot.c 中
在fetch_image_from_partition 中,获取lk logo的时候会先去判断splash这
个分区的名字是否在partition_ent->name中,如果存在则继续。
在 splash_screen_mmc 函数中,会先check splash 分区是否存在,接着会把
splash分区的内容对到对应的logo buf中。
如果分区不存在,分区内容不可读,或者分区图片的大小和fb_display中数值不

匹配,则返回错误,将会选择imageBuffer_rgb888 数组中的内容。

3、 LK Logo by .h

3.1、 第一步 准备工具

(1)convert
(2)rgb2565

(3)png 格式的logo 图片

3.2、 第二步 使用命令将图片重新着色(BGR->RGB)

convert 256X256-LOGO.png -recolor "0 0 1, 0 1 0, 1 0 0" xxx.png

3.3、 第三步 转换成raw

convert -depth 8 logo.jpg rgb:logo_ntd.raw

3.4、 第四步 转换成.h 文件

xxd -i logo_ntd.raw > logo.h

3.5、 将logo.h 放入 bootable/bootloader/lk/platform/msm_shared/include/文

件夹下,并将名字改成splash.h

3.6、修改图片的宽高
#define SPLASH_IMAGE_WIDTH 93
#define SPLASH_IMAGE_HEIGHT 400

将buffer 的名字修改为imageBuffer_rgb888[]

4、.附件代码

4.1、 刷分区代码
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#define FILE_PATH "/data/splash.img"
#define OUT_PATH "dev/block/platform/msm_sdcc.1/by-name/splash"
FILE * openfile(const char *pf );
FILE * openfile1(const char *pf );
char *p;
char *bp = NULL;
unsigned long get_file_size(FILE * pf);
int main(int argc, char * argv[])
{
int err = 0;
char * bp = NULL;
unsigned long size = 0;
p =(char *)malloc(7*1024*1024);
if (p == NULL) {
exit(1);
}
bp =p;
FILE *fp1 = openfile1(OUT_PATH);
FILE *fp = openfile(FILE_PATH);
err = fseek(fp1,0L,SEEK_SET);
if (err != 0)
printf("fseek 1 err is %d\n",err);
size = get_file_size(fp);
printf("file size %d\n",size);
err = fread(p, size,1, fp);
if (err == 0) {
printf("fread fail\n");
goto end;
}
err = fwrite(bp,1, size, fp1);
if (err == 0){
printf("fwrite fail\n");
goto end;
}
end:
fclose(fp);
fclose(fp1);
free(p);
return 0;
}
/*******************************/
/*******************************/
FILE * openfile(const char *pf)
{
FILE *f;
if ((f = fopen(pf,"rb")) == NULL) {
printf("open error for %m\n",errno);
exit(1);
}
printf("open success\n");
return f;
}
FILE * openfile1(const char *pf)
{
FILE *f;
if ((f = fopen(pf,"wb")) == NULL) {
printf("open error for %m\n",errno);
exit(1);
}
printf("open success\n");
return f;
}
unsigned long get_file_size(FILE * pf)
{
unsigned long filesize = -1;
if (pf == NULL)
return filesize;
fseek(pf, 0L, SEEK_END);
filesize = ftell(pf);
fseek(pf, 0L, SEEK_SET);
return filesize;

}

4.2、 镜像文件制作代码
/**
*Copyright(c) 2015 Yangzhou New Telecom Science & Technology Co.,
Ltd. All rights reserved.
*/
/* Change Log
*
* Date Author Description
* ----------------------------------------------------------------------------
* 03/05/2015 Edwin He Production of splash image
*
*
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#define BUF_SIZE 1024
#define LOGO_IMG_OFFSET (12*1024*1024)
#define LOGO_IMG_MAGIC "SPLASH!!"
#define LOGO_IMG_MAGIC_SIZE sizeof(LOGO_IMG_MAGIC) - 1
struct logo_img_header {
unsigned char magic[LOGO_IMG_MAGIC_SIZE]; // "SPLASH!!"
unsigned int width; // logo's width, little endian
unsigned int height; // logo's height, little endian
unsigned int offset;
unsigned char reserved[512-20];
};
/**
* ./a.out width height pic.raw
*/
int main(int argc, char **argv)
{
unsigned char temp[BUF_SIZE] = {};
struct logo_img_header *header = NULL;
int fd = -1, src_fd = -1;
int bytes_read, bytes_write;
char *ptr = NULL;
int ret = 0;
if (argc < 4)
{
printf("Usage: %s width height file.raw\n", argv[0]);
exit (-1);
}
header = (struct logo_img_header *)malloc(sizeof(struct
logo_img_header));
memset (header, 0, sizeof(struct logo_img_header));
header->width = atoi(argv[1]);
header->height = atoi(argv[2]);
memcpy(header->magic, LOGO_IMG_MAGIC, LOGO_IMG_MAGIC_SIZE);
if ((fd = open("splash.img", O_WRONLY | O_CREAT, S_IRUSR|S_IWUSR))
== -1)
{
printf("Failed to open file\n");
exit(-1);
}
if ((src_fd = open(argv[3], O_RDONLY))== -1)
{
printf("Failed to open %s\n", argv[3]);
exit (-1);
}
ret = write(fd, header, sizeof(struct logo_img_header));
if(ret < 0)
{
printf("Failed to write header\n");
exit(-1);
}
while(bytes_read=read(src_fd, temp, BUF_SIZE))
{
if((bytes_read == -1)&&(errno!=EINTR))
break;
else if(bytes_read > 0)
{
ptr = temp;
while(bytes_write = write(fd, ptr, bytes_read))
{
if((bytes_write==-1)&&(errno != EINTR))
break;
else if(bytes_write > 0)
{
ptr += bytes_write;
bytes_read -= bytes_write;
}
}
if(bytes_write == -1)
break;
}
}
close(fd);
close(src_fd);
return 0;
}

原文链接:https://blog.csdn.net/liwei16611/article/details/53457026

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值