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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to