Calculate the matrix for different scaling mode.