• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: 1-bit NSBitmapImageRep?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 1-bit NSBitmapImageRep?


  • Subject: Re: 1-bit NSBitmapImageRep?
  • From: Graham Cox <email@hidden>
  • Date: Fri, 18 Apr 2008 14:17:14 +1000
  • Resent-date: Fri, 18 Apr 2008 14:17:42 +1000
  • Resent-from: Graham Cox <email@hidden>
  • Resent-message-id: <email@hidden>
  • Resent-to: Cocoa-Dev List <email@hidden>

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@hidden)

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:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >1-bit NSBitmapImageRep? (From: Graham Cox <email@hidden>)
 >Re: 1-bit NSBitmapImageRep? (From: Uli Kusterer <email@hidden>)
 >Re: 1-bit NSBitmapImageRep? (From: Graham Cox <email@hidden>)
 >Re: 1-bit NSBitmapImageRep? (From: "Michael Ash" <email@hidden>)

  • Prev by Date: Re: @dynamic and Programmatic Access to Setters
  • Next by Date: Re: Why is [nil aMessage] a no-op?
  • Previous by thread: Re: 1-bit NSBitmapImageRep?
  • Next by thread: Re: 1-bit NSBitmapImageRep?
  • Index(es):
    • Date
    • Thread