The chemistry was right, but what about the temps when you did the change? A decent size (and sometimes small) difference in the temp from old water (in the cup) and new (in his QT) would also cause symptoms similar to SBD. He isn't bloated. In fact, just the opposite. He looks a little thin. You want to feed bettas 2+ meals a day, 4-6 pellets total per day is a good amount, with one day a week fasting. One large meal, or one small meal a day can potentially cause problems.
Poor guy, hope he gets better soon.