As I pointed out to Prasad, these computations are only correct if the viewfinder is always at (0,0). If you ever do square photos, it won't be.  So you need to know the top-left corner of the viewfinder to do the transformation correctly.