Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you set the inputTransform for CIAffineTransform in iOS 5

I've been looking around for a while for an answer to this, but haven't found anything. I'm trying to use the CIAffineTransform thats apart of iOS 5 Beta, and have come across an issue. The documentation says that the 'inputTransform' property accepts an NSAffineTransform, but near as I can tell, there is no way to instantiate one of these in iOS, all the research I've done tells me this particular class is for MacOS (correct me if I'm wrong).

If thats the case, then what value do I put into the inputTransform?

Here's some simple code to explain what I'm trying to accomplish.

CIImage* result = "Some CIImage";


CIFilter* filter = [CIFilter filterWithName:@"CIAffineTransform"];
[filter setValue:result forKey:kCIInputImageKey];

[filter setValue:transform forKey:@"inputTransform"]; //What type/class of value do I set here if I can't use an NSAffineTransform

result = [filter outputImage];

Any help will be greatly apprecriated.

like image 888
Grinneh Avatar asked Aug 10 '11 12:08

Grinneh


2 Answers

I found the solution, I was simply looking in the wrong place.

Instead of using the CIAffineTransform filter on the CIImage, CIImage actually provides a method called:

-(CIImage*) imageByApplyingTransform:(CGAffineTransform)transform

This method returns an image that has the CGAffineTransform argument applied to it.

Hope that helps somebody :)

like image 70
Grinneh Avatar answered Oct 25 '22 14:10

Grinneh


Per the Core Image Filter Reference.

CGAffineTransform xForm = whatever;
[myFilter setValue:[NSValue valueWithBytes:&xForm objCType:@encode(CGAffineTransform)] forKey:@"inputTransform"];
like image 38
William Jockusch Avatar answered Oct 25 '22 12:10

William Jockusch