Don't abort just because libosso failed to initialize
[glmemperf] / data / rotate.py
1 #!/bin/bin/python
2 # -*- encoding: iso-8859-1 -*-
3 # OpenGL ES 2.0 memory performance estimator
4 # Copyright (C) 2009 Nokia
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #
20 # \author Sami Kyöstilä <sami.kyostila@nokia.com>
21 #
22 import sys
23
24 if not len(sys.argv) == 5:
25     print "Usage: %s SOURCE DEST BYTES-PER-PIXEL STRIDE" % sys.argv[0]
26     sys.exit(1)
27
28 fsrc = open(sys.argv[1], "rb")
29 fdst = open(sys.argv[2], "wb")
30 bpp = int(sys.argv[3])
31 stride = int(sys.argv[4])
32
33 lines = []
34 while 1:
35   line = fsrc.read(stride)
36   if not line: break
37   lines.append(line)
38
39 print "%dx%dx => %dx%d" % (stride / bpp, len(lines), len(lines), stride / bpp)
40
41 for x in range(0, stride, bpp):
42   for line in lines:
43     fdst.write(line[x:x+bpp])
44
45 fsrc.close()
46 fdst.close()