开发者

Using UIImagePNGRepresentation

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.

Here is my cod开发者_开发问答e:

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


Judging by your reply to Metalmi, it looks like you're not giving us the actual code you're compiling. If you're actually doing what it looks like you're doing, then you're trying to write data to your application's bundle, which is going to fail because you're not allowed to do that. Can you provide us with the exact code you're trying to execute?


Try this:

NSString *dataFilePath = [[NSBundle mainBundle] pathForResource:@"Picture" ofType:@"png"];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜