tags:

views:

611

answers:

1

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);
A: 

Try this:

NSString *dataFilePath = [[NSBundle mainBundle] pathForResource:@"Picture" ofType:@"png"];
MetaImi
I tried that, but I am getting this error message "Assertion failed: (CGImage), function loadTexture, file Program received signal: “SIGABRT”."Here's my code:// Save the image NSString *dataFilePath = [[NSBundle mainBundle] pathForResource:@"Picture" ofType:@"png"];NSData *imageData = UIImagePNGRepresentation(imageView.image); [imageData writeToFile:dataFilePath atomically:YES];// Load image into textureloadTexture("Picture.png", And the line it crashes at:CGImageRef CGImage = [UIImage imageNamed:[NSString stringWithUTF8String:name]].CGImage;rt_assert(CGImage);