aspect ratio calculations

I am writing a small gui program for a friend that takes the hassle out of using a particular command line program directly. Some of the options available to set are image width, image height, device aspect ratio (DAR) and pixel aspect ratio (PAR). Another option is a flag that maintains either the device aspect ratio or the pixel aspect ratio when one of the other values are changed.

for e.g., if initially
1
2
3
4
5
w = 640px
h = 480px
DAR = 1.333
PAR = 1.000
ratio maintained = DAR


then if the width was changed, for example, the DAR would remain unchanged but the PAR would be recalculated.
Graphics aren't my strong point but I basically get that the image aspect ratio is the w/h, the DAR is the aspect ratio of the target device and the PAR is the ratio of the actual pixel itself. What I don't understand is given the w, h and DAR, how is the PAR calculated? And vice-versa, given the w, h and PAR, how is the DAR calcualted?

Thanks.
Topic archived. No new replies allowed.