| f = open('%s.bmp' % (name)) |
| size = struct.calcsize(fmt) |
| return struct.unpack(fmt, data) |
| (sig, fsize, res1, res2, offset) = read_data("=HLHHL") |
| (hsize, w, h, planes, bpp, comp, imgsize) = read_data("=LllHHLL") |
| out.write("/* AUTOGENERATED BY mklogo.py DO NOT EDIT! */\n\n") |
| out.write("/* source image: %s size: %dx%dx%d */\n" % (name,w,h,bpp)) |
| pitch = ((w*bpp+31)/32)*4 |
| out.write("extern const int logoWidth = %d;\n" % (w)) |
| out.write("extern const int logoHeight = %d;\n" % (h)) |
| out.write("extern const unsigned int logoData[%d*%d]={\n" % (w, h)) |
| # assumes source=32bpp for now |
| pixel = map(ord, data[x*4:x*4+4]) |
| out.write(sep + "0x%02x%02x%02x%02x" % (0xff - pixel[3], pixel[2], pixel[1], pixel[0])) |
| # the C compiler will pad out any missing Y data |