作业
Topic sourcefrom collections import namedtuple
BMPInfo = namedtuple('BMPInfo',('ch1','ch2','size','reserved','offset','headerbits','width','height','num','colornum'))
def bmp_info(data):
info = BMPInfo(*struct.unpack('<ccIIIIIIHH', data[:30]))
if info.ch1 == b'B' and (info.ch2 == b'M' or info.ch2 == b'A'):
return {
'width': info.width,
'height': info.height,
'color': info.colornum
}
return None
- 1
皇甫Yuri