Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 103 lines (83 sloc) 2.898 kB
be6d4d1 change the default recovery assets to be in holograph style
Doug Zongker authored
1 # Copyright (C) 2011 The Android Open Source Project
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 """Script to take a set of frames (PNG files) for a recovery
16 "installing" icon animation and turn it into a base image plus a set
17 of overlays, as needed by the recovery UI code. Run with the names of
18 all the input frames on the command line, in order."""
19
20 import sys
21 try:
22 import Image
23 except ImportError:
24 print "This script requires the Python Imaging Library to be installed."
25 sys.exit(1)
26
27 # Find the smallest box that contains all the pixels which change
28 # between images.
29
30 print "reading", sys.argv[1]
31 base = Image.open(sys.argv[1])
32
33 minmini = base.size[0]-1
34 maxmaxi = 0
35 minminj = base.size[1]-1
36 maxmaxj = 0
37
38 for top_name in sys.argv[2:]:
39 print "reading", top_name
40 top = Image.open(top_name)
41
42 assert base.size == top.size
43
44 mini = base.size[0]-1
45 maxi = 0
46 minj = base.size[1]-1
47 maxj = 0
48
49 h, w = base.size
50 for j in range(w):
51 for i in range(h):
52 b = base.getpixel((i,j))
53 t = top.getpixel((i,j))
54 if b != t:
55 if i < mini: mini = i
56 if i > maxi: maxi = i
57 if j < minj: minj = j
58 if j > maxj: maxj = j
59
60 minmini = min(minmini, mini)
61 maxmaxi = max(maxmaxi, maxi)
62 minminj = min(minminj, minj)
63 maxmaxj = max(maxmaxj, maxj)
64
65 w = maxmaxi - minmini + 1
66 h = maxmaxj - minminj + 1
67
68 # Now write out an image containing just that box, for each frame.
69
70 for num, top_name in enumerate(sys.argv[1:]):
71 top = Image.open(top_name)
72
73 out = Image.new("RGB", (w, h))
74 for i in range(w):
75 for j in range(h):
76 t = top.getpixel((i+minmini, j+minminj))
77 out.putpixel((i, j), t)
78
79 fn = "icon_installing_overlay%02d.png" % (num+1,)
80 out.save(fn)
81 print "saved", fn
82
83 # Write out the base icon, which is the first frame with that box
84 # blacked out (just to make the file smaller, since it's always
85 # displayed with one of the overlays on top of it).
86
87 for i in range(w):
88 for j in range(h):
89 base.putpixel((i+minmini, j+minminj), (0, 0, 0))
90 fn = "icon_installing.png"
91 base.save(fn)
92 print "saved", fn
93
94 # The device_ui_init() function needs to tell the recovery UI the
95 # position of the overlay box.
96
97 print
98 print "add this to your device_ui_init() function:"
99 print "-" * 40
100 print " ui_parameters->install_overlay_offset_x = %d;" % (minmini,)
101 print " ui_parameters->install_overlay_offset_y = %d;" % (minminj,)
102 print "-" * 40
Something went wrong with that request. Please try again.