blob: 142f6147b865de4fbcfc80392587a3203ef59466 [file] [log] [blame]
#!/usr/bin/python
import sys, os, struct
name = "swiftshader"
f = open('%s.bmp' % (name))
out = sys.stdout
def read_data(fmt):
size = struct.calcsize(fmt)
data = f.read(size)
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))
f.seek(offset)
out.write("extern const unsigned int logoData[%d*%d]={\n" % (w, h))
sep = " "
for y in xrange(0,h):
data = f.read(pitch)
for x in xrange(0,w):
# 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]))
sep = ", "
sep = ",\n "
# the C compiler will pad out any missing Y data
out.write("\n};\n")