views:

81

answers:

1

I have an image with tiles that I am splitting up and creating individual tiles with.

However, these images typically contain completely blank areas (tiles in this case) that I wish to exclude. These areas are completely transparent.

Now, how do I go about detecting them? Could read the tile pixel by pixel, by way of NSBitmapImageRep but that doesn't sound very efficient.

So what is the best way of testing the transparency of the tile (they are cropped to a CGImageRef, then converted to an NSImage - if that helps)

+1  A: 

If you don't mind using using a 10.6-only call, then you could try the NSImage method

hitTestRect:withImageDestinationRect:context:hints:flipped:

This would be easier than checking pixel by pixel, but I don't know whether it would be more efficient. Somewhere down the line, those pixels have to be checked...

walkytalky
Looks good to me, thanks!
Nuoji