On Wed, 16 Aug 2017 18:39:56 -0500, Ken Thomases said:

>On Aug 16, 2017, at 6:29 PM, Sean McBride <s...@rogue-research.com> wrote:
>> 
>> 
>> Right, but then I'm back where I started. :(  Because there's
>(apparently) no way to ensure that the NSBitmapImageRep I get is in a
>particular format, and I absolutely need 8 bit per pixel & greyscale.
>
>It's quite old now, but the 10.6 AppKit release notes had a lot of good
>information about working with images in Cocoa viz. Core Graphics.  From
><https://developer.apple.com/library/content/releasenotes/AppKit/RN-
>AppKitOlderNotes/#X10_6Notes>, search for "NSImage, CGImage, and
>CoreGraphics impedance matching" and read from there.
>
>They also have advice about what you're trying to do.  The advice is to
>*not* try to interpret an arbitrary image rep's bitmap data.  It's to
>make a bitmap with the format you desired and draw the source image into
>it.  Then, you have bitmap data in the format you want, for sure.  For
>that, search for "NSBitmapImageRep: CoreGraphics impedance matching and
>performance notes".

Thanks, that's quite helpful!  I know I've read it before, but forgot to 
recheck those release notes, they sure are great, I'm glad Apple writes them!

I also found 'QA1509: Getting the pixel data from a CGImage object' which is 
even older, but was useful too.

I also found vImageBuffer_InitWithCGImage() which has been great!

So my typical data is 1280x1024.  With NSBitmapImageRep I can't get it into an 
NSData in 30 ms, whereas with CGImageCreateWithJPEGDataProvider() + 
vImageBuffer_InitWithCGImage() it takes only 9 ms and produces byte-for-byte 
identical results interestingly enough.  I suspect bitmapData makes a copy 
somewhere.

Cheers,

-- 
____________________________________________________________
Sean McBride, B. Eng                 s...@rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

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

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

Reply via email to