• 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
[Enigmatic semi-solution] Re: Cannot get pixel color from NSBitmapImageRep
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[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


  • Follow-Ups:
    • Re: [Enigmatic semi-solution] Re: Cannot get pixel color from NSBitmapImageRep
      • From: Ken Ferry <email@hidden>
References: 
 >Cannot get pixel color from NSBitmapImageRep (From: David Hirsch <email@hidden>)
 >Re: Cannot get pixel color from NSBitmapImageRep (From: Dave Keck <email@hidden>)
 >Re: Cannot get pixel color from NSBitmapImageRep (From: David Hirsch <email@hidden>)

  • Prev by Date: Re: Releasing NSSearchPathForDirectoriesInDomain causes crash
  • Next by Date: Re: How to tell if NSArrayController has a selected CoreData instance?
  • Previous by thread: Re: Cannot get pixel color from NSBitmapImageRep
  • Next by thread: Re: [Enigmatic semi-solution] Re: Cannot get pixel color from NSBitmapImageRep
  • Index(es):
    • Date
    • Thread