Pulled code from prideout's pxOsdUtil.