Sometimes, the friends reflect the true personality of the person you're dating. It can be that this was a one time thing and he's just insecure but from what you've said, my gut says he's a jerk.
If I were around his friend again and he said something close to this again, I would simply state "I am who I am and if I change it's for me, not to make
you happy. My weight, weight loss, food choices, etc are
not open for discussion. If you have an issue with this you know where the door is. It's your choice."
I would then discuss it in private with the boyfriend after everyone leaves. It's never OK to cheat, it's not appropriate to ogle over someone's half naked girlfriend in front of their SO, it's not OK to let your friends belitting your girlfriend and keep mum about it. These aren't hard concepts. If he argued about any one of them, it's a bad sign in my book.
He doesn't sound like a good person for anyone let alone someone who's trying to conquer some pretty significant issues with food. I'm afraid from your description of him he could lead to some serious "backsliding" into anorexia territory. Please remember to take care of yourself first, mentally and physically, even if that includes getting rid of an emotional parasite. Good luck on difficult discussions and potentially hard choices.