1
Programs / Image functions: Convert Cartesian to Polar coordinates
« on: October 15, 2021, 03:16:20 pm »
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!
Enjoy!
Code: QB64: [Select]
- 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
- O = O + 4
- 'create new image
- prevDest& = _DEST
- _DEST newImg
- yfactor = (1 - (y / (maxy))) * scaley
- _DEST Image
- _FREEIMAGE newImg
- ERASE imgPoints
- _DEST prevDest&
- 'turn checking back on when done!
- _MEMFREE Buffer