[Enigmatic semi-solution] Re: Cannot get pixel color from NSBitmapImageRep
[Enigmatic semi-solution] Re: Cannot get pixel color from NSBitmapImageRep
- Subject: [Enigmatic semi-solution] Re: Cannot get pixel color from NSBitmapImageRep
- From: David Hirsch <email@hidden>
- Date: Thu, 01 Oct 2009 08:52:35 -0700
Well, I can work around it but I don't understand this at all.
Apparently the context is flipped, or getPixelAtX:y: is flipped, or
something. In this code, the first NSLog statement gives all zeros,
and the second gives the intended red color. However flipped returns
NO. Any ideas as to what the heck is going on here?
offscreenRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil
pixelsWide:500
pixelsHigh:300
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSCalibratedRGBColorSpace
bitmapFormat:0
bytesPerRow:0
bitsPerPixel:0];
[offscreenRep retain];
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:[NSGraphicsContext
graphicsContextWithBitmapImageRep:offscreenRep]];
[[NSGraphicsContext currentContext] setShouldAntialias:NO];
[[NSColor colorWithCalibratedRed:0.5 green:0 blue:0 alpha:1.0] set];
[NSBezierPath fillRect:NSMakeRect(0, 0, 41, 259)];
NSLog(@"%@", [offscreenRep colorAtX:40 y:40]);
[NSBezierPath fillRect:NSMakeRect(0, 0, 41, 261)];
NSLog(@"%@", [offscreenRep colorAtX:40 y:40]);
BOOL flipped = [[NSGraphicsContext currentContext] isFlipped];
-Dave
_______________________________________________
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