On Mon, Feb 23, 2009 at 7:42 PM, Michael Ash <michael....@gmail.com> wrote:

> On Mon, Feb 23, 2009 at 4:51 PM, David Alter <alterconsult...@gmail.com>
> wrote:
> > I need to get a CGImage out of a NSBitmapImageRep. This needs to work in
> > 10.4.
> > I tried doing this by setting the bitmap as the graphics context and then
> > creating the image form the context. This gives me an
> CGBitmapContextCreate:
> > unsupported parameter combination. Here is the code
> >
> > NSGraphicsContext * context = [NSGraphicsContext
> > graphicsContextWithBitmapImageRep:offscreenRep];
> >
> > CGContextRef bitmapContext = (CGContextRef)[context graphicsPort];
> >
> > CGImageRef image = CGBitmapContextCreateImage (bitmapContext);
> >
> > I suspect there is a better way to do this. Does anyone have any
> > suggestions.
>
> Just call CGImageCreate. Most of the parameters can be obtained by
> simply querying the NSBitmapImageRep, and the remainder are not
> terribly difficult to create yourself, being either constants or
> fairly easy to construct.
>
> That should work fine.

As I have progressed with this, I would like to do some additional drawing
in my  NSBitmapImageRep. Is there a way that I can set it as my
NSGraphicsContext. As I noted
earlier NSGraphicsContext graphicsContextWithBitmapImageRep: is giving me an
error.

What I want to do is create the NSBitmapImageRep from a jpg. Draw into the
image and extract a CGImageRef out. I need to be able to access
the individual pixels of the image. Maybe there is a better way to do this?

thanks for the help
-dave
_______________________________________________

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

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

Reply via email to