Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kCGImagePropertyOrientation incompatible pointer

Tags:

ios

core-image

I'm implementing Auto Enhancing in my app. My code goes like this:

CIImage *toBeEnhancedImage = [CIImage imageWithCGImage:_originalImage.CGImage];

NSDictionary *options = @{CIDetectorImageOrientation : [[toBeEnhancedImage properties] valueForKey:kCGImagePropertyOrientation]};

NSArray *adjustments = [toBeEnhancedImage autoAdjustmentFiltersWithOptions:options];

Before Running the code, I get the following error next to NSDictionary:

Incompatible pointer types sending 'const CFStringRef (AKA 'const struct__CFString const)to parameter of type NSString*

When i run the code, it crashes. I know what the error means but the code is actually taken from Apple's documentation and it doesn't work! is there a workaround?

like image 537
HusseinB Avatar asked Jul 08 '26 08:07

HusseinB


1 Answers

You should type cast your CFStringRef variable to NSString *. Change the second line of your code with below lines:

NSDictionary *options = nil;
if([[toBeEnhancedImage properties] valueForKey:(NSString *)kCGImagePropertyOrientation] == nil)
{
    options = @{CIDetectorImageOrientation : [NSNumber numberWithInt:1]};
}
else
{
   options = @{CIDetectorImageOrientation : [[toBeEnhancedImage properties] valueForKey:(NSString *)kCGImagePropertyOrientation]};
}
like image 87
Apurv Avatar answered Jul 13 '26 19:07

Apurv



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!