On Jul 27, 2012, at 7:45 AM, Graham Cox wrote: > On 27/07/2012, at 10:36 PM, Vojtěch Meluzín wrote: > >> I need to create and manipulate an image, which I could access directly >> from memory and at the same time be able to use system drawing functions >> for optimization. On Windows I can create a memory bitmap, but it seems it >> is on possible on Mac, or is it? Note that I don't want to do any >> conversions from handles to memory etc., the whole point is optimization. > > What have you tried? > > There are all sorts of ways you can manipulate images, here's one: > > [NSBitmapImageRep initWithBitMapDataPlanes:.....]; > > by passing existing pointer to memory in bitPlanes, it will wrap that memory > in the necessary bitmap structure rather than create a new one. > > there are also some similar functions in CGImage (though it's more work to > wrap an existing block of memory), and the vImage framework for image > processing.
There's also CGBitmapContext. You can draw to that as well as manipulate its memory. You can't draw _from_ it directly, but you can obtain a CGImage from it using CGBitmapContextCreateImage(). Also, if you use NSBitmapImageRep but let it allocate the data, you can still obtain it using -bitmapData. It's a good idea to read the section about image technologies in the Snow Leopard AppKit release notes. Search for "NSImage, CGImage, and CoreGraphics impedance matching" and "NSBitmapImageRep: CoreGraphics impedance matching and performance notes". <https://developer.apple.com/library/mac/releasenotes/Cocoa/AppKitOlderNotes.html#X10_6Notes> Regards, Ken _______________________________________________ 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