A generalized matrix version of Rennie's inequality