• 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: 2nd Try: Access raw pixel data of a CIImage?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 2nd Try: Access raw pixel data of a CIImage?


  • Subject: Re: 2nd Try: Access raw pixel data of a CIImage?
  • From: "Adam R. Maxwell" <email@hidden>
  • Date: Sat, 7 Jul 2007 11:48:37 -0700


On Jul 7, 2007, at 10:14, Simon Raisin wrote:

I've heard that there are 3rd party frameworks that can do this, but there
has to be a built-in, supported method.


I realize that CIImage isn't really an "image", more of a recipe for how to
draw an image. Thus, couldn't I draw the image to an off-screen buffer and
then read the data from there?

There are various ways to do it (some of which leak memory, so be careful). Here's what I use in an NSAnimation subclass:


// filter is a CIFilter ivar, bitmapData is a CFDataRef ivar

    CIImage *image = [filter valueForKey:@"outputImage"];
    CGRect rect = [image extent];

CGImageRef cgImage = [[[NSGraphicsContext currentContext] CIContext] createCGImage:image fromRect:rect];

    CFDataSetLength(bitmapData, 0);

CGImageDestinationRef imDest = CGImageDestinationCreateWithData(bitmapData, kUTTypeTIFF, 1, NULL);
CGImageDestinationAddImage(imDest, cgImage, NULL);
CGImageDestinationFinalize(imDest);
CFRelease(imDest);
CGImageRelease(cgImage);


NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithData:(NSData *)bitmapData];

This gives you an NSBitmapImageRep instance, so you can do whatever you want with the pixel data at that point. Erik Buck's method looks more interesting, though.

--
Adam


_______________________________________________

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: 2nd Try: Access raw pixel data of a CIImage?
      • From: "Simon Raisin" <email@hidden>
References: 
 >2nd Try: Access raw pixel data of a CIImage? (From: "Simon Raisin" <email@hidden>)

  • Prev by Date: Re: 2nd Try: Access raw pixel data of a CIImage?
  • Next by Date: Re: 2nd Try: Access raw pixel data of a CIImage?
  • Previous by thread: 2nd Try: Access raw pixel data of a CIImage?
  • Next by thread: Re: 2nd Try: Access raw pixel data of a CIImage?
  • Index(es):
    • Date
    • Thread