Re: CIFilter - can not change value
Re: CIFilter - can not change value
- Subject: Re: CIFilter - can not change value
- From: Richard Salvatierra <email@hidden>
- Date: Fri, 28 Oct 2005 15:57:26 -0400
FYI - my problem was with the context. In this case I used
NSGraphicsContext with the process from:
http://developer.apple.com/samplecode/Reducer/listing16.html
- (NSImage*) updateImageWithHueFilter: (NSImage*)theImage
{
float hueValue = 2.45;
CIFilter *myHueFilter;
CIImage *effectedImage;
NSBitmapImageRep *bitmapRep;
bitmapRep = BitmapImageRepFromNSImage(theImage);
// Create an NSGraphicsContext that draws into the
NSBitmapImageRep, and make it current.
NSGraphicsContext *nsContext = [NSGraphicsContext
graphicsContextWithBitmapImageRep: bitmapRep];
effectedImage = [[CIImage alloc] initWithBitmapImageRep:
bitmapRep];
myHueFilter = [CIFilter filterWithName:@"CIHueAdjust"];
[myHueFilter setDefaults];
[myHueFilter setValue: effectedImage forKey: @"inputImage"];
[myHueFilter setValue: [NSNumber numberWithFloat: hueValue]
forKey: @"inputAngle"];
effectedImage = [myHueFilter valueForKey:@"outputImage"];
// Get a CIContext from the NSGraphicsContext, and use it to
draw the CIImage into the NSBitmapImageRep.
[[nsContext CIContext] drawImage:effectedImage
atPoint:CGPointZero fromRect:[effectedImage extent]];
// Restore the previous graphics context and state.
[NSGraphicsContext restoreGraphicsState];
NSImage *theImageOutput = [[NSImage alloc] initWithSize:
NSMakeSize(extent.size.width, extent.size.height)];
NSCIImageRep *ciImageRep = [NSCIImageRep imageRepWithCIImage:
effectedImage];
[theImageOutput addRepresentation:ciImageRep];
[NSGraphicsContext restoreGraphicsState];
return [theImageOutput autorelease];
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden