• 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
Brightness -> Alpha mod? (was "Re: NSBezierPath bugs? (Contains point and fill)")
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Brightness -> Alpha mod? (was "Re: NSBezierPath bugs? (Contains point and fill)")


  • Subject: Brightness -> Alpha mod? (was "Re: NSBezierPath bugs? (Contains point and fill)")
  • From: Scott Harper <email@hidden>
  • Date: Thu, 13 Oct 2005 04:34:19 -0600

I can't answer your question but I'm curious about something... You're iterating through /all/ the pixels in the rectangle checking whether each is inside the polygon? So for a 100x100 bounding rectangle you're doing 10,000 tests against the polygon? That seems incredibly inefficient - does it have to be done that way?




Indeed I am, and it DOES seem rather inefficient, though I have no idea how else to do it. I figured that since it's a one-shot thing JUST after you let go of the mouse, then it wouldn't be THAT big of an issue to wait an extra fraction of a second. The time needed DOES get visibly longer (especially on my poor old G3 400) the larger the area selected.


Does anyone know of a more efficient way to get this done? Is there perhaps a method I can use for GRABBING all the pixels within an NSBezierPath explicitly? (Like [image drawAtPoint:p fromPath:bezierPath operation:NSCompositeSourceOver]; or something?)


Assuming you have an NSImage that represents the contents of your view, create an image with a size set to the size of your path's bounds. Set the graphics context to draw into your newly created image and use NSBezierPath's setClip API to set up the clipping path. Then draw your original image. Your new image should then only contain pixels within your path; all other pixels should be transparent (or whatever you set the background to be).

Thanks for the response! I also received one like this from a Mr. Randolph leading me to an example on apple's site which accomplishes a similar goal. I'll look into implementing one of these two suggestions, so thank you both VERY much! ^_^ Incedentally, is there a reasonably quick way to transform the darkness of each pixel to its alpha value as well? Thus, full black becomes completely opaque, and full white becomes completely transparent?


--Scott
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSBezierPath bugs? (Contains point and fill) (From: Scott Harper <email@hidden>)
 >Re: NSBezierPath bugs? (Contains point and fill) (From: Andy Armstrong <email@hidden>)
 >Re: NSBezierPath bugs? (Contains point and fill) (From: Scott Harper <email@hidden>)
 >Re: NSBezierPath bugs? (Contains point and fill) (From: Ricky Sharp <email@hidden>)

  • Prev by Date: Re: where's showAllApplications ?
  • Next by Date: cocoabuilder password?
  • Previous by thread: Re: NSBezierPath bugs? (Contains point and fill)
  • Next by thread: Re: NSBezierPath bugs? (Contains point and fill)
  • Index(es):
    • Date
    • Thread