문제

Is there any sample code or example for CITemperatureAndTint? I have read its documentation but i need some example to implement it.

도움이 되었습니까?

해결책

CIFilter *yourFilter = [CIFilter filterWithName:@"CITemperatureAndTint"];
[yourFilter setValue:yourInputImage forKey:@"inputImage"];
[yourFilter setValue:[CIVector vectorWithX:6500 Y:500] forKey:@"inputNeutral"]; // Default value: [6500, 0] Identity: [6500, 0]
[yourFilter setValue:[CIVector vectorWithX:1000 Y:630] forKey:@"inputTargetNeutral"]; // Default value: [6500, 0] Identity: [6500, 0]
CIImage *resultImage = [yourFilter valueForKey: @"outputImage"];
UIImage *resultOutputImage = [UIImage imageWithCGImage:[context createCGImage:resultImage fromRect:resultImage.extent]];    

You can see what values for color temperature give you which colors in this wikipedia link.

For Reference

CITemperatureAndTint has three input parameters: Image, Neutral and TargetNeutral. Neutral and TargetNeutral are of 2D CIVector type, and in both of them, note that the first dimension refers to Temperature and the second dimension refers to Tint. What the CITemperatureAndTint filter basically does is computing a matrix that adapts RGB values from the source white point defined by Neutral (srcTemperature, srcTint) to the target white point defined by TargetNeutral (dstTemperature, dstTint), and then applying this matrix on the input image (using the CIColorMatrix filter). If Neutral and TargetNeutral are of the same values, then the image will not change after applying this filter. I don't know the implementation details about iPhoto, but I think the two slide bars give the Temperature and Tint changes (i.e. differences between source and target Temperature and Tint values already) that you want to add to the source image.

다른 팁

well there is no specific example that is made for CITemperatureAndTint but you can get the code to demonstrates the use of an NSImage as an off-screen drawing destination.

The URL for that code is https://developer.apple.com/library/mac/#samplecode/Tinted_Image/Introduction/Intro.html#//apple_ref/doc/uid/DTS10000412-Intro-DontLinkElementID_2

I am sure you can modify it to use CITemperatureAndTint or modify the existing code to meet your needs.

Hope this helps.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top