I wrote this function as part of Vedit, the image editor made in QB64, but I wanted to share it because I can't recall seeing one like it here. I used the Wiki example for modifying image data in memory and adapted it to read the pixel data, then write them back into a new image with a bit of math for the new x and y coordinates.
Enjoy!
mx = maxx / 2
my = maxy / 2
O = Buffer.OFFSET 'We start at this offset
O_Last = Buffer.OFFSET + maxx * maxy * 4 'We stop when we get to this offset
maxp = maxx * maxy
'use on error free code ONLY!
p = p + 1
y
= FIX((p
/ maxp
) * maxy
) x
= p
- (FIX((p
/ maxp
) * maxy
) * maxx
) O = O + 4
'create new image
scaley
= (maxx
/ 2 / _PI) IF scaley
> maxy
THEN scaley
= maxy
/ 2 yfactor = (1 - (y / (maxy))) * scaley
PSET (mx
- (yfactor
* SIN(2 * _PI * (1 - (x
/ maxx
)))), my
- (yfactor
* COS(2 * _PI * (1 - (x
/ maxx
))))), _RGBA(imgPoints
(y
, x
, 2), imgPoints
(y
, x
, 1), imgPoints
(y
, x
, 0), imgPoints
(y
, x
, 3)) 'turn checking back on when done!