Archive for August 28, 2007

Tuesday, August 28, 2007

How to Implement a Magic Wand Tool

I haven’t had time to read it yet, but this looks like another great Cocoa graphics coding tutorial from Andy Finnell:

There is a lot more involved in implementing a magic wand tool than I originally thought. Although generating a bitmap mask that selects pixels is the obvious thing that I had to do, implementing the marching ants around the bitmap selection was also surprisingly involved. After figuring out both the image mask generation and marching ants, I decided the article wouldn’t be complete unless I also implemented a basic copy operation, so the user could copy the selection into another application. Although not technically part of the magic wand tool, implementing a copy command shows how you would actually use the selection generated by the magic wand tool.