好不容易做好了initlogo.rle,可是放进/root目录后,显示非常不正常。原来initlogo.rle是565rgb rle格式压缩的,可是屏是24位显示,这就难怪显示糟糕了。没什么好想的,自己转换吧!
思路:
- 原本显示initlogo.rle图片是在init进程被执行的(system/core/init/init.c),if( load_565rle_image(INIT_IMAGE_FILE) ) 如果没有则显示android文字。
- 修改load_565rle_image函数如下:
int load_565rle_image(char *fn)
{
...................
/*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;
}*/
parse_initlogo_rle(count,bits,ptr);munmap(data, s.st_size);
fb_update(&fb);
fb_close(&fb);
close(fd);
unlink(fn);
return 0;
.....................
} - 那么在load_565rle_image(char *n)前得对parse_initlogo_rle(count,bits,ptr); 函数有定义拉:
void parse_initlogo_rle(unsigned short* lcd_base,unsigned short* data_base,int size)
{ unsigned long width, height;
unsigned short * bmap;
int x,y,i,j;
unsigned short count;
bmap = data_base;
unsigned char *fb =(unsigned char*) lcd_base;
while(size > 3) {
unsigned int n = bmap[0];
while(n) {
unsigned short val = bmap[1];
*fb++ = ((val&0x001F )<<3);//B
*fb++ = ((val&0x07E0 )>>3);//G
*fb++ = ((val&0xF800 )>>8);//R
fb++;//the forth byte not use
n--;
}
size -= 4;
bmap += 2;
}
} - 这样就完成了rgb565到24位转换了。
注:对16位到24位转换详细可参考:http://www.linuxgraphics.cn/graphics/image_processing_color_depth_convert.html