Re: I need float resolution bitmap data from a JPG using CIImage or similar helper
Re: I need float resolution bitmap data from a JPG using CIImage or similar helper
- Subject: Re: I need float resolution bitmap data from a JPG using CIImage or similar helper
- From: Jens Alfke <email@hidden>
- Date: Tue, 1 Jun 2010 11:15:04 -0700
On May 31, 2010, at 5:40 PM, Robert Lorentz wrote:
> CGContextRef context = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGBitmapFloatComponents);
>
> CGColorSpaceRelease(colorSpace);
>
> // draw the CIImage to the 'context'... this is probably the line that's wrong
> [image drawInRect:NSMakeRect(0, 0, width, height) fromRect:[self bounds] operation:NSCompositeSourceIn fraction 1.0];
You created a context, but you never told AppKit to draw into it, so it’s just drawing into whatever the current context is at that moment.
You’ll need to do something like this:
NSGraphicsContext *nsContext = [NSGraphicsContext graphicsContextWithGraphicsPort: context flipped: NO];
NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext: nsContext];
[image drawInRect: ……..];
[NSGraphicsContext restoreGraphicsState];
I’ve never actually tried doing this, so I’m not certain the above code will work, but it looks as though it should.
—Jens_______________________________________________
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