Thanks for this, and to others who suggested the same thing - it works GREAT, and was a trivial change to make in my app. It also allowed me to cut out a whole bunch of stuff having to do with maintaining the bitmap cache - I do love it when I can chop lots of code out and things work better ;-)


Thanks again,


G.


On 18 Apr 2008, at 12:07 pm, Michael Ash wrote:
There is an easy, although deeply non-obvious, way to do 100% correct
hit testing with any stylistic variations, and even to hit test with
fill versus stroke. In fact, you're almost there, and just need to
take it a little bit further.

The answer is, instead of drawing into a big context and then checking
the pixel value of the location in question, you draw into a very
teeny context with a proper transform set up. Create a 1x1 context,
set up the proper affine transform to make that pixel be the one
you're hit testing, then draw whatever it is you're drawing.
Afterwards, check your one pixel: if it's dark, you hit, if it's
light, you missed.

You're still wasting the memory for an 8-bit context, but at least
it's only 7 bits wasted. :)

Mike
_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/graham.cox%40bigpond.com

This email sent to [EMAIL PROTECTED]

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to