load an icon from the data directory

def mp_icon(filename):
        '''load an icon from the data directory'''
        # we have to jump through a lot of hoops to get an OpenCV image
        # when we may be in a package zip file
        try:
                import pkg_resources
                name = __name__
                if name == "__main__":
                        name = "MAVProxy.modules.mavproxy_map.mp_tile"
                raw = pkg_resources.resource_stream(name, "data/%s" % filename).read()
        except Exception:
                raw = open(os.path.join(__file__, 'data', filename)).read()
        imagefiledata = cv.CreateMatHeader(1, len(raw), cv.CV_8UC1)
        cv.SetData(imagefiledata, raw, len(raw))
        img = cv.DecodeImage(imagefiledata, cv.CV_LOAD_IMAGE_COLOR)
        return img