Search code examples
iphoneiosobjective-cuiimagecore-graphics

Image Circular Wrap in iOS


I have a problem - I want to create a circular wrap function which will wrap an image as depicted below:

Image Wrap

This is available in OSX however is not available on iOS.

My logic so far has been:

Split the image up into x sections and for each section:

  1. Rotate alpha degrees
  2. Scale the image in the x axis to create a diamond shaped 'warped' effect of the image
  3. Rotate back 90 - atan((h / 2) / (w / 2))
  4. Translate the offset

My problem is that this seems inaccurate and I have been unable to mathematically figure out how to do this correctly - any help would be massively appreciated.

Link to OSX docs for CICircularWrap:

https://developer.apple.com/library/archive/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CICircularWrap


Solution

  • Apple have added CICircularWrap to iOS 9

    https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CICircularWrap

    Wraps an image around a transparent circle.

    Localized Display Name

    Circular Wrap Distortion

    Availability

    Available in OS X v10.5 and later and in iOS 9 and later.