code: def RDvcgt(s):
      
      # See
      # http://developer.apple.com/documentation/GraphicsImaging/Reference/ColorSync_Manager/Reference/reference.html#//apple_ref/c/tdef/CMVideoCardGammaType
      assert s[0:4] == 'vcgt'
      tagtype, = struct.unpack('>L', s[8:12])
      if tagtype != 0:
          return s[8:]
      if tagtype == 0:
          # Table.
          channels, count, size = struct.unpack('>3H', s[12:18])
          if size == 1:
              fmt = 'B'
          elif size == 2:
              fmt = 'H'
          else:
              return s[8:]
          n = len(s[18:]) // size
          t = struct.unpack('>%d%s' % (n, fmt), s[18:])
          t = group(t, count)
          return size, t
      return s[8:]
docs: Convert Apple CMVideoCardGammaType.