Added bitmap rescaling to prevent memory leaking on mac.