Moved scaling code to gfx.Util