Android 5.X与Android4.X版本机器人动画的区别以及制作动画的方法

在线体验各类最新模型,更有模型 免费Token 额度领取!
立即体验
简介: 今天翻了下墙,解决了一直以来的疑惑问题:为什么Android5.0以及6.0的recovery版本,机器人动画怎么就只有一张图片?这个问题,我百思不得其解,看了很多网文,也只是有了个概念。请参考以下文档,这是我从谷歌Android开源网拉下来的原文:https://source.

今天翻了下墙,解决了一直以来的疑惑问题:

为什么Android5.0以及6.0的recovery版本,机器人动画怎么就只有一张图片?

这个问题,我百思不得其解,看了很多网文,也只是有了个概念。

请参考以下文档,这是我从谷歌Android开源网拉下来的原文:

https://source.android.com/devices/tech/ota/device_code

Recovery UI images

Android 5.x

The recovery user interface consists images. Ideally, users never interact with the UI: During a normal update, the phone boots into recovery, fills the installation progress bar, and boots back into the new system without input from the user. In the event of a system update problem, the only user action that can be taken is to call customer care.

An image-only interface obviates the need for localization. However, as of Android 5.x the update can display a string of text (e.g. "Installing system update...") along with the image. For details, see Localized recovery text.


The installing animation is represented as a single PNG image with different frames of the animation interlaced by row (which is why Figure 2 appears squished). For example, for a 200x200 seven-frame animation, create a single 200x1400 image where first frame is rows 0, 7, 14, 21, ...; the second frame is rows 1, 8, 15, 22, ...; etc. The combined image includes a text chunk that indicates the number of animation frames and the number of frames per second (FPS). The tool bootable/recovery/interlace-frames.py takes a set of input frames and combines them into the necessary composite image used by recovery.
efault images are available in different densities and are located inbootable/recovery/res$DENSITY/images (e.g., bootable/recovery/res-hdpi/images). To use a static image during installation, you need only provide the icon_installing.png image and set the number of frames in the animation to 0 (the error icon is not animated; it is always a static image).
以上文档意思就是说,Android5.x以上的版本,机器人的动画是PNG图片和帧动画组成的,我们可以使用recovery目录下的interlace-frames.py这个python脚本来进行合成,具体的合成方法可以参考这位新浪网友的文章,亲身试过,问题已经解决,那么,既然可以这么来合成,我就可以把android原生态的动画给换了,因为这个机器人实在是丑。

 Android 4.x and earlier
The Android 4.x and earlier recovery UI uses the error image (shown above) and the installing animation plus several overlay images:


During installation, the on-screen display is constructed by drawing the icon_installing.png image, then drawing one of the overlay frames on top of it at the proper offset. Here, a red box is superimposed to highlight where the overlay is placed on top of the base image:


Subsequent frames are displayed by drawing only the next overlay image atop what's already there; the base image is not redrawn.

The number of frames in the animation, desired speed, and x- and y-offsets of the overlay relative to the base are set by member variables of the ScreenRecoveryUI class. When using custom images instead of default images, override the Init() method in your subclass to change these values for your custom images (for details, see ScreenRecoveryUI). The script bootable/recovery/make-overlay.py can assist in converting a set of image frames to the "base image + overlay images" form needed by recovery, including computing of the necessary offsets.

Default images are located in bootable/recovery/res/images. To use a static image during installation, you need only provide the icon_installing.png image and set the number of frames in the animation to 0 (the error icon is not animated; it is always a static image).

上面说了这么多,其实也是把这上面的图片通过make-overlay.py这个python脚本来对4.x以及早期版本的android recovery的图片进行合成,中间让我们看到的转转转那个overlay的效果就是上面这些组图合成的,合成最终的图片存放在bootable/recovery/res/images这个路径下。


根据以上参考官方的文档理解,顺便参考一个网友的更改方案:


转自 http://qiushao.net/2015/12/20/replace_android_recovery_picture/

替换recovery动画图片

最近在做一个项目是android 系统各部分动画的定制,有一个模块是recovery界面的定制,包括用户升级,重置系统时的动画效果修改。与recovery相关的代码在android4.4/bootable/recovery目录下。
我大概看了一下与界面相关的代码,觉得应该只是替换几张图片,修改一下参数而已,没啥工作量,所以也就不细看具体实现了。但当美工把图交给我后,我把图片替换后,发现美工给的彩色的图片变成灰度图的效果了,而且图片被拉伸,显示不全。这咋回事啊,问同事,百度,google 一圈之后,也找不到原因。只能 read the fucking source code 了。

周末加班看了一下午的recovery代码,终于找到原因啦。原来是recovery的图片资源必须为png格式,且不能带alhpa通道信息。真是个大坑。
相关代码在 android4.4/bootable/recovery/minui/resources.c文件中:



int res_create_surface(const char* name, gr_surface* pSurface) {
	printf("qiushao: res_create_surface: /res/images/%s.png\n", name);
    ...
    int color_type = info_ptr->color_type;
    int bit_depth = info_ptr->bit_depth;
    int channels = info_ptr->channels;
    ...
    size_t width = info_ptr->width;
    size_t height = info_ptr->height;
    size_t stride = (color_type == PNG_COLOR_TYPE_GRAY ? 1 : 4) * width;
    size_t pixelSize = stride * height;

    ...

	printf("qiushao: color_type = %d\n", color_type);
	printf("qiushao: bit_depth = %d\n", bit_depth);
	printf("qiushao: channels = %d\n", channels);
	printf("qiushao: width = %lu\n", width);
	printf("qiushao: height = %lu\n", height);
	printf("qiushao: stride = %lu\n", stride);
	printf("qiushao: alpha = %d\n", alpha);
		
    unsigned int y;
	if (channels == 3 || (channels == 1 && !alpha)) {
		printf("qiushao: channels == 3 || (channels == 1 && !alpha)\n");
        for (y = 0; y < height; ++y) {
            unsigned char* pRow = pData + y * stride;
            png_read_row(png_ptr, pRow, NULL);

            int x;
            for(x = width - 1; x >= 0; x--) {
                int sx = x * 3;
                int dx = x * 4;
                unsigned char r = pRow[sx];
                unsigned char g = pRow[sx + 1];
                unsigned char b = pRow[sx + 2];
                unsigned char a = 0xff;
                pRow[dx    ] = r; // r
                pRow[dx + 1] = g; // g
                pRow[dx + 2] = b; // b
                pRow[dx + 3] = a;
            }
        }
    } else {
    	printf("qiushao: channels != 3 && (channels == 1 && !alpha)\n");
        for (y = 0; y < height; ++y) {
            unsigned char* pRow = pData + y * stride;
            png_read_row(png_ptr, pRow, NULL);
        }
    }

    *pSurface = (gr_surface) surface;

转自 http://qiushao.net/2015/12/20/replace_android_recovery_picture/

替换recovery动画图片

最近在做一个项目是android 系统各部分动画的定制,有一个模块是recovery界面的定制,包括用户升级,重置系统时的动画效果修改。与recovery相关的代码在android4.4/bootable/recovery目录下。
我大概看了一下与界面相关的代码,觉得应该只是替换几张图片,修改一下参数而已,没啥工作量,所以也就不细看具体实现了。但当美工把图交给我后,我把图片替换后,发现美工给的彩色的图片变成灰度图的效果了,而且图片被拉伸,显示不全。这咋回事啊,问同事,百度,google 一圈之后,也找不到原因。只能 read the fucking source code 了。

周末加班看了一下午的recovery代码,终于找到原因啦。原来是recovery的图片资源必须为png格式,且不能带alhpa通道信息。真是个大坑。
相关代码在 android4.4/bootable/recovery/minui/resources.c文件中:



这个函数将图片文件的数据读取到内存,我在其中输出了一些调试信息,输出图片的 color_type, channels 等信息。查看LOG发现,android原生的图片 channels == 3,channels 即色彩通道个数,等于 3 的话,意味着只有 R,G,B 三个通道的信息,没有 ALPHA 通道信息!这段代码的逻辑是如果channels 不等于3, 则按channels = 1 来处理,即灰度图。

美工给的图片是带 alpha通道信息的,即channels = 4,被当成灰度图像来处理了,怪不得显示的效果是灰度图像。我一直以为 png 图像就只有一种格式,都是带有 alpha通道的。。。

使用图像处理工具(photoshop 或者 gimp),将美工给的图片去掉 alpha 通道信息,再替换recovery 的图片,编译,替换recovery.img ,reboot -r 。图片终于正常显示啦。




转自 http://qiushao.net/2015/12/20/replace_android_recovery_picture/

替换recovery动画图片

最近在做一个项目是android 系统各部分动画的定制,有一个模块是recovery界面的定制,包括用户升级,重置系统时的动画效果修改。与recovery相关的代码在android4.4/bootable/recovery目录下。
我大概看了一下与界面相关的代码,觉得应该只是替换几张图片,修改一下参数而已,没啥工作量,所以也就不细看具体实现了。但当美工把图交给我后,我把图片替换后,发现美工给的彩色的图片变成灰度图的效果了,而且图片被拉伸,显示不全。这咋回事啊,问同事,百度,google 一圈之后,也找不到原因。只能 read the fucking source code 了。

周末加班看了一下午的recovery代码,终于找到原因啦。原来是recovery的图片资源必须为png格式,且不能带alhpa通道信息。真是个大坑。
相关代码在 android4.4/bootable/recovery/minui/resources.c文件中:


目录
相关文章
|
Android开发 开发者
Android自定义view之利用drawArc方法实现动态效果
本文介绍了如何通过Android自定义View实现动态效果,重点使用`drawArc`方法完成圆弧动画。首先通过`onSizeChanged`进行测量,初始化画笔属性,设置圆弧相关参数。核心思路是不断改变圆弧扫过角度`sweepAngle`,并调用`invalidate()`刷新View以实现动态旋转效果。最后附上完整代码与效果图,帮助开发者快速理解并实践这一动画实现方式。
299 0
|
机器人 网络安全 数据安全/隐私保护
autMan奥特曼机器人-对接Docker版本NTQQ详细教程
本文介绍了如何在服务器上搭建NTQQ机器人,通过官方NTQQ对接各框架,实现QQ登录的稳定运行。文章提到了需要准备一台服务器和相应的软件,并详细描述了通过SSH链接服务器、创建文件夹和配置文件、编辑配置文件地址端口、运行容器等步骤。同时,文章还介绍了VNC连接的使用和配置,以及使用watchtower进行NTQQ的更新。文章总结起来就是在服务器上搭建NTQQ机器人,实现QQ登录的稳定性和自动登录功能,同时提供了更新和维护的方法。
1406 3
autMan奥特曼机器人-对接Docker版本NTQQ详细教程
|
10月前
|
XML 编解码 Android开发
非常经典的Android开发问题-mipmap图标目录和drawable图标目录的区别和适用场景实战举例-优雅草卓伊凡
非常经典的Android开发问题-mipmap图标目录和drawable图标目录的区别和适用场景实战举例-优雅草卓伊凡
810 0
非常经典的Android开发问题-mipmap图标目录和drawable图标目录的区别和适用场景实战举例-优雅草卓伊凡
|
12月前
|
安全 数据库 Android开发
在Android开发中实现两个Intent跳转及数据交换的方法
总结上述内容,在Android开发中,Intent不仅是活动跳转的桥梁,也是两个活动之间进行数据交换的媒介。运用Intent传递数据时需注意数据类型、传输大小限制以及安全性问题的处理,以确保应用的健壯性和安全性。
698 11
Android.mk(makefile)中几个符号的区别:=、 :=、 ?=、 +=
本文解释了在Android.mk文件中使用的几种赋值符号的区别,包括`=`(基本赋值)、`:=`(覆盖赋值)、`?=`(条件赋值,仅在变量未赋值时操作)、`+=`(追加赋值),并通过实验演示了这些符号的具体行为和效果。
1183 1
|
Android开发 Kotlin
Android经典面试题之Kotlin的==和===有什么区别?
本文介绍了 Kotlin 中 `==` 和 `===` 操作符的区别:`==` 用于比较值是否相等,而 `===` 用于检查对象身份。对于基本类型,两者行为相似;对于对象引用,`==` 比较值相等性,`===` 检查引用是否指向同一实例。此外,还列举了其他常用比较操作符及其应用场景。
536 94
|
编译器 Android开发 开发者
Android经典面试题之Kotlin中Lambda表达式和匿名函数的区别
Lambda表达式和匿名函数都是Kotlin中强大的特性,帮助开发者编写简洁而高效的代码。理解它们的区别和适用场景,有助于选择最合适的方式来解决问题。希望本文的详细讲解和示例能够帮助你在Kotlin开发中更好地运用这些特性。
454 9
|
缓存 Java Shell
Android 系统缓存扫描与清理方法分析
Android 系统缓存从原理探索到实现。
1041 15
Android 系统缓存扫描与清理方法分析
|
人工智能 机器人 Shell
AI语音机器人安装方法 AI机器人安装代码
AI语音机器人安装方法 AI机器人安装代码
378 2
|
网络协议 机器人 C++
KUKA机器人Socket通讯配置方法:技术干货分享
【10月更文挑战第7天】在现代自动化生产线上,KUKA机器人凭借其高效、灵活和精确的特点,成为众多企业的首选。为了实现KUKA机器人与其他设备或系统之间的数据交互,Socket通讯配置显得尤为重要。本文将详细介绍KUKA机器人Socket通讯的配置方法,帮助大家在工作中更好地掌握这一技术。
2389 2

热门文章

最新文章