def _process_bitmap(bitmap):
 fh = file(bitmap, 'rb')
 try:
  data = fh.read()
 finally:
  fh.close()
 if (len(data) <= 54):
  raise Exception("bitmap doesn't contain enough data.")
 if (data[:2] != 'BM'):
  raise Exception("bitmap doesn't appear to to be a valid bitmap image.")
 data = data[2:]
 size = unpack('<L', data[:4])[0]
 size -= 54
 size += 12
 data = data[4:]
 data = data[12:]
 (width, height) = unpack('<LL', data[:8])
 data = data[8:]
 if (width > 65535):
  raise Exception('bitmap: largest image width supported is 65k.')
 if (height > 65535):
  raise Exception('bitmap: largest image height supported is 65k.')
 (planes, bitcount) = unpack('<HH', data[:4])
 data = data[4:]
 if (bitcount != 24):
  raise Exception("bitmap isn't a 24bit true color bitmap.")
 if (planes != 1):
  raise Exception('bitmap: only 1 plane supported in bitmap image.')
 compression = unpack('<L', data[:4])[0]
 data = data[4:]
 if (compression != 0):
  raise Exception('bitmap: compression not supported in bitmap image.')
 data = data[20:]
 header = pack('<LHHHH', 12, width, height, 1, 24)
 data = (header + data)
 return (width, height, size, data)

def _process_bitmap ( bitmap ) : fh = file ( bitmap , 'rb' ) try : data = fh . read ( ) finally : fh . close ( ) if ( len ( data ) <= 54 ) : raise Exception ( "bitmap doesn't contain enough data." ) if ( data [ : 2 ] != 'BM' ) : raise Exception ( "bitmap doesn't appear to to be a valid bitmap image." ) data = data [ 2 : ] size = unpack ( '<L' , data [ : 4 ] ) [ 0 ] size -= 54 size += 12 data = data [ 4 : ] data = data [ 12 : ] ( width , height ) = unpack ( '<LL' , data [ : 8 ] ) data = data [ 8 : ] if ( width > 65535 ) : raise Exception ( 'bitmap: largest image width supported is 65k.' ) if ( height > 65535 ) : raise Exception ( 'bitmap: largest image height supported is 65k.' ) ( planes , bitcount ) = unpack ( '<HH' , data [ : 4 ] ) data = data [ 4 : ] if ( bitcount != 24 ) : raise Exception ( "bitmap isn't a 24bit true color bitmap." ) if ( planes != 1 ) : raise Exception ( 'bitmap: only 1 plane supported in bitmap image.' ) compression = unpack ( '<L' , data [ : 4 ] ) [ 0 ] data = data [ 4 : ] if ( compression != 0 ) : raise Exception ( 'bitmap: compression not supported in bitmap image.' ) data = data [ 20 : ] header = pack ( '<LHHHH' , 12 , width , height , 1 , 24 ) data = ( header + data ) return ( width , height , size , data )
convert a 24 bit bitmap into the modified internal format used by windows .