X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/46eada874a6e63143589f437713648ca8fb90f71..c8841d1493e0d19085990c9e331dd85c4da45d8e:/misc/scripts/png2c.py?ds=sidebyside diff --git a/misc/scripts/png2c.py b/misc/scripts/png2c.py index 5f451aa05d..e1ea837324 100755 --- a/misc/scripts/png2c.py +++ b/misc/scripts/png2c.py @@ -56,9 +56,14 @@ for path in sys.argv[1:]: # Try to naively get its size if necessary if with_size: - width = bytes[19] + 16*bytes[18] + 256*bytes[17] + 4096*bytes[16] - height = bytes[23] + 16*bytes[22] + 256*bytes[21] + 4096*bytes[20] - size_suffix = "_%dx%d" % (width, height) + def getInt(start): + """ Convert 4 bytes in network byte order to an integer. """ + return 16777216*bytes[start] + \ + 65536*bytes[start+1] + \ + 256*bytes[start+2] + \ + bytes[start+3]; + + size_suffix = "_%dx%d" % (getInt(16), getInt(20)) # Create the C header text = "/* %s - %d bytes */\n" \