What is the fastest way to trim an image (NSImage or CGImageRef) so that all transparent areas around the image are removed?
I'd imagine I could look at each pixel starting from the top and determine its alpha value, but maybe there's another (faster) way.
Thanks, Mark.
PS: My usecase:
I'm using QLThumbnailImageCreate
to generate thumbnails of files. The problem is that all images returned by that call are of equal width and height.
For example, if I create a thumbnail for a photo of the dimensions 300x500, the resulting preview would be of the same width and height with transparent areas added at the top and bottom to preserve the aspect ratio.