• 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: Erik Buck <email@hidden>
  • Date: Sat, 7 Jul 2007 14:35:41 -0400

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?


Again, any suggestions would be much appreciated.

-CxT

Of course you can render a CIImage to a buffer and read the data from there.


Just use Apple's helpfully provided NSOpenGLPixelBuffer class along with NSOpenGLContext using - setPixelBuffer:cubeMapFace:mipMapLevel:currentVirtualScreen:

http://developer.apple.com/documentation/Cocoa/Reference/ ApplicationKit/Classes/NSOpenGLPixelBuffer_Class/Reference/ Reference.html#//apple_ref/doc/c_ref/NSOpenGLPixelBuffer

http://developer.apple.com/documentation/Cocoa/Reference/ ApplicationKit/Classes/NSOpenGLContext_Class/Reference/ Reference.html#//apple_ref/occ/instm/NSOpenGLContext/ setPixelBuffer:cubeMapFace:mipMapLevel:currentVirtualScreen:

Apple provides sample code for reading the pixels of a pixel buffer that has a current opengl context: (Note: you could have found this with a little googling http://developer.apple.com/samplecode/ QuartzComposerOffline/listing1.html see -bitmapImageForTime:)



// Here is some sample code to draw a CIImage into a pixel buffer with a current opengl context:
(Note: this is really just basic opengl programming that has nothing to do with Cocoa specifically)
- (void)updateWithCIImage:(CIImage *)aCIImage
{ // Draw aCIImage scalled as necessary to fill entire pixel buffer.
// As a side effect, this method may change the current glMatrixMode
if(nil != aCIImage)
{
CGRect extent = [aCIImage extent];


      glViewport(0, 0, [self width], [self height]);
      glMatrixMode(GL_PROJECTION);
      glPushMatrix();
      glLoadIdentity();
      glOrtho (0, extent.size.width, 0, extent.size.height, -1, 1);
      glMatrixMode(GL_MODELVIEW);
      glPushMatrix();
      glLoadIdentity();

// ciContext previously created as CIContext instance in the normal way
[ciContext drawImage:aCIImage atPoint:CGPointMake(0.0f, 0.0f) fromRect:extent];


      glPopMatrix();
      glMatrixMode(GL_PROJECTION);
      glPopMatrix();
      glFlush();
   }
}


_______________________________________________

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


  • Prev by Date: 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: Re: 2nd Try: Access raw pixel data of a CIImage?
  • Next by thread: Core data / bindings with two one->many relationships
  • Index(es):
    • Date
    • Thread