3 # Copyright 2011 Anthony Tong <atong@trustedcs.com>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 tool to preconvert an icon file to a x11 property as expected
20 width, length, [argb pixels]
30 print "convert_to_ewm_prop <infile> <outfile>"
37 im = PIL.Image.open(argv[1])
38 fp = open(argv[2], 'w')
40 var_name = os.path.basename(argv[2])
41 if var_name.endswith('.h'):
42 var_name = var_name[:-2]
44 fp.write("static unsigned long %s_prop [] = {\n" % var_name)
45 fp.write(" %d, %d\n" % im.size)
48 for pixel in im.getdata():
54 fp.write(" , %du" % pixel)
62 if __name__ == '__main__':
63 sys.exit(main(sys.argv))