Refactor pixel/color conversion