Search code examples
objective-cuiimagetransparencypixelalpha

Retrieving last non-transparent pixel position of a transparent UIImage


How can I retrieve the top-left/top-right/bottom-left/bottom-right non-transparent pixel of a transparent image?


Solution

  • You can extract the pixel data of the image and compare alpha values (either by iterating through the returned array or (more effectively) by changing the linked algorithm to compare the points in place, thus evading the need of the NSArray with colors).