• 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
Re: Getting colour data at specified point in an NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting colour data at specified point in an NSImage


  • Subject: Re: Getting colour data at specified point in an NSImage
  • From: Michael Watson <email@hidden>
  • Date: Wed, 14 Mar 2007 13:15:01 -0400

Drawing the bitmap isn't really the problem. I'll be drawing into the bitmap and then compositing several bitmaps into an NSImage. Later, I'll need to scan bytes inside the bitmap data for some information I want.

The only reason I'm using NSImage is because of - drawInRect:fromRect:operation:fraction:, of which there is no equivalent in NSBitmapImageRep. (I don't want to redraw entire bitmaps, just sections of them.)


-- mikey

On 14 Mar, 2007, at 11:29, email@hidden wrote:

Hi,
As matter of fact, you can't really lock focus on bitmap image representation.
lock focus on image will create a NSCachedImageRep which use offscreen window as drawing buffer.


If you would like to draw to the bitmap, you might have to use quartz's bitmap context
or something like this:
image = [[NSImage alloc] initWithSize:imageSize];
[image lockFocus];
[[NSColor colorWithCalibratedWhite:1.0 alpha:1.0] set];
NSRectFillUsingOperation(NSMakeRect(0, 0, imageSize.width, imageSize.height), NSCompositeCopy);
[[NSBitmapImageRep alloc] initWithFocusedViewRect: NSMakeRect(0, 0, imageSize.width, imageSize.height)];
[image unlockFocus];
[release];


But the second approach is much more in-efficient.(draw to offscreen window and then copy it to bitmap buffer)
HTH,
James


On Mar 14, 2007, at 6:32 AM, Michael Watson wrote:

Using NO for isPlanar has no effect, but yeah, later I'd be using planar data.

Either way, it's probably a good idea to use NO for testing purposes until I figure this out. :-)


-- mikey

On 13 Mar, 2007, at 18:25, Shawn Erickson wrote:

On 3/13/07, Michael Watson <email@hidden> wrote:
Oops, already spotted a mistake. This should be my initializer:

bitmapRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:imageSize.width
pixelsHigh:imageSize.height
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:YES
colorSpaceName:NSCalibratedRGBColorSpace
bytesPerRow:0 // let NSBitmapImageRep take care of this
bitsPerPixel:32];

You are passing YES for isPlanar. Are you sure you really want a planar image?


Note sure if somehow that is causing you a problem.

-Shawn

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: Getting colour data at specified point in an NSImage
      • From: email@hidden
References: 
 >Getting colour data at specified point in an NSImage (From: Michael Watson <email@hidden>)
 >Re: Getting colour data at specified point in an NSImage (From: Michael Watson <email@hidden>)
 >Re: Getting colour data at specified point in an NSImage (From: Michael Watson <email@hidden>)
 >Re: Getting colour data at specified point in an NSImage (From: email@hidden)

  • Prev by Date: Re: NSDictionary descriptionWithLocale
  • Next by Date: Survey: API reference "metadata"
  • Previous by thread: Re: Getting colour data at specified point in an NSImage
  • Next by thread: Re: Getting colour data at specified point in an NSImage
  • Index(es):
    • Date
    • Thread