Need help using UIImagePNGRepresentation
- by mustanggal511
I'm trying to save a UIImageView image to a png file, and then use that file as a GLTexture.
I'm having trouble with this, when I try to run my code in the simulator, XCode says it succeeded, but the simulator crashes with no error messages. Can someone help me with this?
Here is my code:
NSString *dataFilePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Picture.png"];
NSData *imageData = UIImagePNGRepresentation(imageView.image);
[imageData writeToFile:dataFilePath atomically:YES];
// Load image into texture
loadTexture("Picture.png", &Input, &renderer);