(If you continue to stretch the image beyond this size the algorithm adjusts this parameter)

Distort the Image

Stretching the image is achieved by dividing the image into parts. The Stretched Side and the Compressed Side. The demarcation point is the Target point. Anything on the Origin side of the Target it stretched from the image border – anything on the opposite side is compressed towards the image border.

In the Source Code this is labeled “//reverse mapping”.

Localizing the Warp

Localizing control of the warp is a simple matter of finding the distance of a pixel to the imaginary line segment created by the Origin Point and the Target Point.

In the Source Code this is the “distance” function.

The distance is normalized by diving it with the Minimum Warp Size. If the distance between Origin and Target (Pythagorean Theorem) exceeds the Minimum Warp Size the distance is used.

Normalizing results (d) is a value between 0 and 1 that is used as the control in a linear interpolation between the Source pixel (uu,vv) and the Target Pixel (x,y).

uu = d * x + uu - uu * d;

vv = d * y + vv - vv * d;

I hope I shed some light on the code for the programmers – I’m sorry if I bored the rest.