Re: Faster way to test pixels?
Re: Faster way to test pixels?
- Subject: Re: Faster way to test pixels?
- From: Jens Alfke <email@hidden>
- Date: Sun, 25 May 2008 00:13:08 -0700
On 24 May '08, at 10:55 PM, Graham Cox wrote:
The purpose is to test whether a given rect intersects a rendered
object (path), not just test a point against it.
There are geometric techniques for doing this, that wouldn't require
working with pixels. Computing the bounding box of a Bézier curve is
very easy, so you can usually trivially reject most of them by
checking the rects for intersection. For the rest, you have to flatten
them into polygons and test each segment. (Doesn't Quartz 2D have
functions to do this?)
Is there any faster way of doing this than just iterating over the
pixels like this? I can't think of anything but someone might have a
bright idea.
If you do test against pixels, work with the raw pixmap instead of
making an Obj-C call to get every pixel. Get the pointer to its pixel
data, and use the rowbytes and the pixel size to iterate over pixels.
If the pixmap is always in a known format, it's pretty easy. (Sounds
like it's 8-bit grayscale, which is as easy as it gets, with one byte
per pixel.)
—Jens
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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