xref: /aosp_15_r20/frameworks/base/cmds/bootanimation/FORMAT.md (revision d57664e9bc4670b3ecf6748a746a57c557b6bc9e)
1*d57664e9SAndroid Build Coastguard Worker# bootanimation format
2*d57664e9SAndroid Build Coastguard Worker
3*d57664e9SAndroid Build Coastguard Worker## zipfile paths
4*d57664e9SAndroid Build Coastguard Worker
5*d57664e9SAndroid Build Coastguard WorkerThe system selects a boot animation zipfile from the following locations, in order:
6*d57664e9SAndroid Build Coastguard Worker
7*d57664e9SAndroid Build Coastguard Worker    /system/media/bootanimation.zip
8*d57664e9SAndroid Build Coastguard Worker    /oem/media/bootanimation.zip
9*d57664e9SAndroid Build Coastguard Worker
10*d57664e9SAndroid Build Coastguard Worker## zipfile layout
11*d57664e9SAndroid Build Coastguard Worker
12*d57664e9SAndroid Build Coastguard WorkerThe `bootanimation.zip` archive file includes:
13*d57664e9SAndroid Build Coastguard Worker
14*d57664e9SAndroid Build Coastguard Worker    desc.txt - a text file
15*d57664e9SAndroid Build Coastguard Worker    part0  \
16*d57664e9SAndroid Build Coastguard Worker    part1   \  directories full of PNG frames
17*d57664e9SAndroid Build Coastguard Worker    ...     /
18*d57664e9SAndroid Build Coastguard Worker    partN  /
19*d57664e9SAndroid Build Coastguard Worker
20*d57664e9SAndroid Build Coastguard Worker## desc.txt format
21*d57664e9SAndroid Build Coastguard Worker
22*d57664e9SAndroid Build Coastguard WorkerThe first line defines the general parameters of the animation:
23*d57664e9SAndroid Build Coastguard Worker
24*d57664e9SAndroid Build Coastguard Worker    WIDTH HEIGHT FPS [PROGRESS]
25*d57664e9SAndroid Build Coastguard Worker
26*d57664e9SAndroid Build Coastguard Worker  * **WIDTH:** animation width (pixels)
27*d57664e9SAndroid Build Coastguard Worker  * **HEIGHT:** animation height (pixels)
28*d57664e9SAndroid Build Coastguard Worker  * **FPS:** frames per second, e.g. 60
29*d57664e9SAndroid Build Coastguard Worker  * **PROGRESS:** whether to show a progress percentage on the last part
30*d57664e9SAndroid Build Coastguard Worker      + The percentage will be displayed with an x-coordinate of 'c', and a
31*d57664e9SAndroid Build Coastguard Worker        y-coordinate set to 1/3 of the animation height.
32*d57664e9SAndroid Build Coastguard Worker
33*d57664e9SAndroid Build Coastguard WorkerNext, provide an optional line for dynamic coloring attributes, should dynamic coloring be used.
34*d57664e9SAndroid Build Coastguard WorkerSee the dyanmic coloring section for format details. Skip if you don't use dynamic coloring.
35*d57664e9SAndroid Build Coastguard Worker
36*d57664e9SAndroid Build Coastguard WorkerIt is followed by a number of rows of the form:
37*d57664e9SAndroid Build Coastguard Worker
38*d57664e9SAndroid Build Coastguard Worker    TYPE COUNT PAUSE PATH [FADE [#RGBHEX [CLOCK1 [CLOCK2]]]]
39*d57664e9SAndroid Build Coastguard Worker
40*d57664e9SAndroid Build Coastguard Worker  * **TYPE:** a single char indicating what type of animation segment this is:
41*d57664e9SAndroid Build Coastguard Worker      + `p` -- this part will play unless interrupted by the end of the boot
42*d57664e9SAndroid Build Coastguard Worker      + `c` -- this part will play to completion, no matter what
43*d57664e9SAndroid Build Coastguard Worker      + `f` -- same as `p` but in addition the specified number of frames is being faded out while
44*d57664e9SAndroid Build Coastguard Worker        continue playing. Only the first interrupted `f` part is faded out, other subsequent `f`
45*d57664e9SAndroid Build Coastguard Worker        parts are skipped
46*d57664e9SAndroid Build Coastguard Worker  * **COUNT:** how many times to play the animation, or 0 to loop forever until boot is complete
47*d57664e9SAndroid Build Coastguard Worker  * **PAUSE:** number of FRAMES to delay after this part ends
48*d57664e9SAndroid Build Coastguard Worker  * **PATH:** directory in which to find the frames for this part (e.g. `part0`)
49*d57664e9SAndroid Build Coastguard Worker  * **FADE:** _(ONLY FOR `f` TYPE)_ number of frames to fade out when interrupted where `0` means
50*d57664e9SAndroid Build Coastguard Worker              _immediately_ which makes `f ... 0` behave like `p` and doesn't count it as a fading
51*d57664e9SAndroid Build Coastguard Worker              part
52*d57664e9SAndroid Build Coastguard Worker  * **RGBHEX:** _(OPTIONAL)_ a background color, specified as `#RRGGBB`
53*d57664e9SAndroid Build Coastguard Worker  * **CLOCK1, CLOCK2:** _(OPTIONAL)_ the coordinates at which to draw the current time (for watches):
54*d57664e9SAndroid Build Coastguard Worker      + If only `CLOCK1` is provided it is the y-coordinate of the clock and the x-coordinate
55*d57664e9SAndroid Build Coastguard Worker        defaults to `c`
56*d57664e9SAndroid Build Coastguard Worker      + If both `CLOCK1` and `CLOCK2` are provided then `CLOCK1` is the x-coordinate and `CLOCK2` is
57*d57664e9SAndroid Build Coastguard Worker        the y-coodinate
58*d57664e9SAndroid Build Coastguard Worker      + Values can be either a positive integer, a negative integer, or `c`
59*d57664e9SAndroid Build Coastguard Worker          - `c` -- will centre the text
60*d57664e9SAndroid Build Coastguard Worker          - `n` -- will position the text n pixels from the start; left edge for x-axis, bottom edge
61*d57664e9SAndroid Build Coastguard Worker            for y-axis
62*d57664e9SAndroid Build Coastguard Worker          - `-n` -- will position the text n pixels from the end; right edge for x-axis, top edge
63*d57664e9SAndroid Build Coastguard Worker            for y-axis
64*d57664e9SAndroid Build Coastguard Worker          - Examples:
65*d57664e9SAndroid Build Coastguard Worker              * `-24` or `c -24` will position the text 24 pixels from the top of the screen,
66*d57664e9SAndroid Build Coastguard Worker                centred horizontally
67*d57664e9SAndroid Build Coastguard Worker              * `16 c` will position the text 16 pixels from the left of the screen, centred
68*d57664e9SAndroid Build Coastguard Worker                vertically
69*d57664e9SAndroid Build Coastguard Worker              * `-32 32` will position the text such that the bottom right corner is 32 pixels above
70*d57664e9SAndroid Build Coastguard Worker                and 32 pixels left of the edges of the screen
71*d57664e9SAndroid Build Coastguard Worker
72*d57664e9SAndroid Build Coastguard WorkerThere is also a special TYPE, `$SYSTEM`, that loads `/system/media/bootanimation.zip`
73*d57664e9SAndroid Build Coastguard Workerand plays that.
74*d57664e9SAndroid Build Coastguard Worker
75*d57664e9SAndroid Build Coastguard Worker## clock_font.png
76*d57664e9SAndroid Build Coastguard Worker
77*d57664e9SAndroid Build Coastguard WorkerThe file used to draw the time on top of the boot animation. The font format is as follows:
78*d57664e9SAndroid Build Coastguard Worker  * The file specifies glyphs for the ascii characters 32-127 (0x20-0x7F), both regular weight and
79*d57664e9SAndroid Build Coastguard Worker    bold weight.
80*d57664e9SAndroid Build Coastguard Worker  * The image is divided into a grid of characters
81*d57664e9SAndroid Build Coastguard Worker  * There are 16 columns and 6 rows
82*d57664e9SAndroid Build Coastguard Worker  * Each row is divided in half: regular weight glyphs on the top half, bold glyphs on the bottom
83*d57664e9SAndroid Build Coastguard Worker  * For a NxM image each character glyph will be N/16 pixels wide and M/(12*2) pixels high
84*d57664e9SAndroid Build Coastguard Worker
85*d57664e9SAndroid Build Coastguard Worker## progress_font.png
86*d57664e9SAndroid Build Coastguard Worker
87*d57664e9SAndroid Build Coastguard WorkerThe file used to draw the boot progress in percentage on top of the boot animation. The font format
88*d57664e9SAndroid Build Coastguard Workerfollows the same specification as the one described for clock_font.png.
89*d57664e9SAndroid Build Coastguard Worker
90*d57664e9SAndroid Build Coastguard Worker## loading and playing frames
91*d57664e9SAndroid Build Coastguard Worker
92*d57664e9SAndroid Build Coastguard WorkerEach part is scanned and loaded directly from the zip archive. Within a part directory, every file
93*d57664e9SAndroid Build Coastguard Worker(except `trim.txt` and `audio.wav`; see next sections) is expected to be a PNG file that represents
94*d57664e9SAndroid Build Coastguard Workerone frame in that part (at the specified resolution). For this reason it is important that frames be
95*d57664e9SAndroid Build Coastguard Workernamed sequentially (e.g. `part000.png`, `part001.png`, ...) and added to the zip archive in that
96*d57664e9SAndroid Build Coastguard Workerorder.
97*d57664e9SAndroid Build Coastguard Worker
98*d57664e9SAndroid Build Coastguard Worker## trim.txt
99*d57664e9SAndroid Build Coastguard Worker
100*d57664e9SAndroid Build Coastguard WorkerTo save on memory, textures may be trimmed by their background color.  trim.txt sequentially lists
101*d57664e9SAndroid Build Coastguard Workerthe trim output for each frame in its directory, so the frames may be properly positioned.
102*d57664e9SAndroid Build Coastguard WorkerOutput should be of the form: `WxH+X+Y`. Example:
103*d57664e9SAndroid Build Coastguard Worker
104*d57664e9SAndroid Build Coastguard Worker    713x165+388+914
105*d57664e9SAndroid Build Coastguard Worker    708x152+388+912
106*d57664e9SAndroid Build Coastguard Worker    707x139+388+911
107*d57664e9SAndroid Build Coastguard Worker    649x92+388+910
108*d57664e9SAndroid Build Coastguard Worker
109*d57664e9SAndroid Build Coastguard WorkerIf the file is not present, each frame is assumed to be the same size as the animation.
110*d57664e9SAndroid Build Coastguard Worker
111*d57664e9SAndroid Build Coastguard Worker## audio.wav
112*d57664e9SAndroid Build Coastguard Worker
113*d57664e9SAndroid Build Coastguard WorkerEach part may optionally play a `wav` sample when it starts. To enable this, add a file
114*d57664e9SAndroid Build Coastguard Workerwith the name `audio.wav` in the part directory.
115*d57664e9SAndroid Build Coastguard Worker
116*d57664e9SAndroid Build Coastguard Worker## exiting
117*d57664e9SAndroid Build Coastguard Worker
118*d57664e9SAndroid Build Coastguard WorkerThe system will end the boot animation (first completing any incomplete or even entirely unplayed
119*d57664e9SAndroid Build Coastguard Workerparts that are of type `c`) when the system is finished booting. (This is accomplished by setting
120*d57664e9SAndroid Build Coastguard Workerthe system property `service.bootanim.exit` to a nonzero string.)
121*d57664e9SAndroid Build Coastguard Worker
122*d57664e9SAndroid Build Coastguard Worker## protips
123*d57664e9SAndroid Build Coastguard Worker
124*d57664e9SAndroid Build Coastguard Worker### PNG compression
125*d57664e9SAndroid Build Coastguard Worker
126*d57664e9SAndroid Build Coastguard WorkerUse `zopflipng` if you have it, otherwise `pngcrush` will do. e.g.:
127*d57664e9SAndroid Build Coastguard Worker
128*d57664e9SAndroid Build Coastguard Worker    for fn in *.png ; do
129*d57664e9SAndroid Build Coastguard Worker        zopflipng -m ${fn} ${fn}.new && mv -f ${fn}.new ${fn}
130*d57664e9SAndroid Build Coastguard Worker        # or: pngcrush -q ....
131*d57664e9SAndroid Build Coastguard Worker    done
132*d57664e9SAndroid Build Coastguard Worker
133*d57664e9SAndroid Build Coastguard WorkerSome animations benefit from being reduced to 256 colors:
134*d57664e9SAndroid Build Coastguard Worker
135*d57664e9SAndroid Build Coastguard Worker    pngquant --force --ext .png *.png
136*d57664e9SAndroid Build Coastguard Worker    # alternatively: mogrify -colors 256 anim-tmp/*/*.png
137*d57664e9SAndroid Build Coastguard Worker
138*d57664e9SAndroid Build Coastguard Worker### creating the ZIP archive
139*d57664e9SAndroid Build Coastguard Worker
140*d57664e9SAndroid Build Coastguard Worker    cd <path-to-pieces>
141*d57664e9SAndroid Build Coastguard Worker    zip -0qry -i \*.txt \*.png \*.wav @ ../bootanimation.zip *.txt part*
142*d57664e9SAndroid Build Coastguard Worker
143*d57664e9SAndroid Build Coastguard WorkerNote that the ZIP archive is not actually compressed! The PNG files are already as compressed
144*d57664e9SAndroid Build Coastguard Workeras they can reasonably get, and there is unlikely to be any redundancy between files.
145*d57664e9SAndroid Build Coastguard Worker
146*d57664e9SAndroid Build Coastguard Worker### Dynamic coloring
147*d57664e9SAndroid Build Coastguard Worker
148*d57664e9SAndroid Build Coastguard WorkerDynamic coloring is a render mode that draws the boot animation using a color transition.
149*d57664e9SAndroid Build Coastguard WorkerIn this mode, instead of directly rendering the PNG images, it treats the R, G, B, A channels
150*d57664e9SAndroid Build Coastguard Workerof input images as area masks of dynamic colors, which interpolates between start and end colors
151*d57664e9SAndroid Build Coastguard Workerbased on animation progression.
152*d57664e9SAndroid Build Coastguard Worker
153*d57664e9SAndroid Build Coastguard WorkerTo enable it, add the following line as the second line of desc.txt:
154*d57664e9SAndroid Build Coastguard Worker
155*d57664e9SAndroid Build Coastguard Worker    dynamic_colors PATH #RGBHEX1 #RGBHEX2 #RGBHEX3 #RGBHEX4
156*d57664e9SAndroid Build Coastguard Worker
157*d57664e9SAndroid Build Coastguard Worker  * **PATH:** file path of the part to apply dynamic color transition to.
158*d57664e9SAndroid Build Coastguard Worker    Any part before this part will be rendered in the start colors.
159*d57664e9SAndroid Build Coastguard Worker    Any part after will be rendered in the end colors.
160*d57664e9SAndroid Build Coastguard Worker  * **RGBHEX1:** the first start color (masked by the R channel), specified as `#RRGGBB`.
161*d57664e9SAndroid Build Coastguard Worker  * **RGBHEX2:** the second start color (masked by the G channel), specified as `#RRGGBB`.
162*d57664e9SAndroid Build Coastguard Worker  * **RGBHEX3:** the third start color (masked by the B channel), specified as `#RRGGBB`.
163*d57664e9SAndroid Build Coastguard Worker  * **RGBHEX4:** the forth start color (masked by the A channel), specified as `#RRGGBB`.
164*d57664e9SAndroid Build Coastguard Worker
165*d57664e9SAndroid Build Coastguard WorkerThe end colors will be read from the following system properties:
166*d57664e9SAndroid Build Coastguard Worker
167*d57664e9SAndroid Build Coastguard Worker  * persist.bootanim.color1
168*d57664e9SAndroid Build Coastguard Worker  * persist.bootanim.color2
169*d57664e9SAndroid Build Coastguard Worker  * persist.bootanim.color3
170*d57664e9SAndroid Build Coastguard Worker  * persist.bootanim.color4
171*d57664e9SAndroid Build Coastguard Worker
172*d57664e9SAndroid Build Coastguard WorkerWhen missing, the end colors will default to the start colors, effectively producing no color
173*d57664e9SAndroid Build Coastguard Workertransition.
174*d57664e9SAndroid Build Coastguard Worker
175*d57664e9SAndroid Build Coastguard WorkerPrepare your PNG images so that the R, G, B, A channels indicates the areas to draw color1,
176*d57664e9SAndroid Build Coastguard Workercolor2, color3 and color4 respectively.
177