Chunhao
Chunhao

Reputation: 170

How to convert UIImageView to CGImageRef?

CGImageRef inImage = (__bridge CGImageRef)(self.captureImage.image);
NSLog(@"%zu",inImage);

Why doesn't this work?? It said "NULL". How can I change image to CGImageRef??

Upvotes: 0

Views: 62

Answers (1)

rmaddy
rmaddy

Reputation: 318924

Assuming self.captureImage is your (poorly named) UIImageView, then you need:

CGImageRef inImage = self.captureImage.image.CGImage;

To be more clear:

UIImageView *imageView = self.captureImage;
UIImage *image = imageView.image;
CGImageRef inImage = image.CGImage;

Upvotes: 1

Related Questions