Jason Segel lost weight because he was worried how his body would look on the big screen.

The 'How I Met Your Mother' star, who recently adopted a healthier lifestyle and lost more than 40 pounds, decided to slim down when he discovered he would be appearing shirtless in the movie 'Sex Tape,' which he is currently filming alongside Cameron Diaz.

The 33-year-old actor told Us Weekly magazine: ''It is R-rated and I'm not in shape for no reason.

''This time when I take my shirt off, I've made a promise to myself, it doesn't have to be funny.''

Jason, who split from Michelle Williams earlier this year, overhauled his diet and started exercising regularly over the summer for the film, which began shooting in Boston last month.

He said: ''I've just been living healthy, exercising, eating right - no more midnight pizzas.''

A source told the MailOnline website that Jason, who is now dating model and actress, Bojana Novakovic, decided to lose weight after ending his relationship with Michelle in March.

The insider said: ''They decided the relationship just couldn't work with Michelle in New York and Jason's commitments here but it doesn't mean he wasn't heartbroken.

''He discovered he wasn't as hungry as he normally is and that helped him lose weight, then it just became routine.''