Re: NSImageRep.imageFileTypes() doesnt work...
Re: NSImageRep.imageFileTypes() doesnt work...
- Subject: Re: NSImageRep.imageFileTypes() doesnt work...
- From: "John C. Randolph" <email@hidden>
- Date: Tue, 30 Jul 2002 10:22:24 -0700
On Tuesday, July 30, 2002, at 02:34 AM, Marco Binder wrote:
PS: I still havent found a convenient and efficient way to enumerate
all the
pixels contained in an NSBezierPath. You would help me alot if you
knew an
answer...
NSBezierPaths don't have pixels.
If you want all of the points that define a path, you can get them like
this:
@interface PathPointsEnumerator : NSObject
{
NSBezierPath *target;
unsigned int index;
}
- (id) initWithBezierPath:(NSBezierPath *) path;
- (NSValue *) nextPoint;
@end
@implementation PathPointsEnumerator
+ enumeratorWithPath: (NSBezierPath *) path { return [[[self alloc]
initWithBezierPath:path] autorelease]; }
- initWithBezierPath:(NSBezierPath *) path
{
if (self = [super init])
{
target = path;
index = [path elementCount];
}
return self;
}
- (NSValue *) nextPoint
{
if (index--)
{
NSPoint points[3];
NSBezierPathElement thisElement = [target elementAtIndex:index
associatedPoints:points];
return [NSValue valueWithPoint: points[0]];
}
return nil;
}
@end
Note that the example above doesn't deal with curveTo: segments. You
can send the path a -flatten message before enumerating its points.
-jcr
John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.