Economic Rent and Opportunity Cost

I do not get how inelastic supply curve would entirely produce economic rent, while an perfectly elastic supply curve would produce entirely opportunity cost.

Can someone explain how this works?