Cube map to fisheye projection

Hello, i am new to this stuff and i would like to know how can someone turn a cube map image to fisheye (or a normal image to fish eye)

P.S: I would be delighted if someone could provide me an algorithm or even pseudocode.

It is easy to derive mathematically (done it before, but don’t have it in front of me, otherwise I would post it). If you are looking for example code, google for fisheye quake and download the C source for it (if you do this I would suggest using a trig substitutions to optimize out the atan2 and stuff that is slow in fragment shaders).