iPhone:CGBitmapContextCreateImage() 仅适用于模拟器
我创建了一个使用 CoreGraphics 创建图像的应用程序。使用 iPhone 模拟器 (OS 3.1 beta3) 时,图像会出现在屏幕上,但当我在设备上运行应用程序时,图像不会出现在屏幕上。这可能是什么原因造成的?
从上下文中提取图像并将其放入图像视图中的代码片段如下所示:
...
ImageResultViewController *resultViewController = [[ImageResultViewController alloc] initWithNibName:nil bundle:nil];
// Extract resulting image from context
UIImage *renderedImage = [[UIImage imageWithCGImage:CGBitmapContextCreateImage(context)] retain];
[resultViewController presentImage:renderedImage];
[renderedImage release];
[self.navigationController pushViewController:resultViewController animated:YES];
[resultViewController release];
CGContextRelease(context);
提前致谢!
斯特凡
I created an app which creates an image by using CoreGraphics. The images appears on the screen when using the iPhone Simulator (OS 3.1 beta3) but not when I run the application on the device. What could be the cause of this?
The code snipped which extracts the image from the context and puts it in an image view looks like this:
...
ImageResultViewController *resultViewController = [[ImageResultViewController alloc] initWithNibName:nil bundle:nil];
// Extract resulting image from context
UIImage *renderedImage = [[UIImage imageWithCGImage:CGBitmapContextCreateImage(context)] retain];
[resultViewController presentImage:renderedImage];
[renderedImage release];
[self.navigationController pushViewController:resultViewController animated:YES];
[resultViewController release];
CGContextRelease(context);
Thanks in advance!
Stefan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
啊啊,这花了我很长时间。这是一个老问题,模拟器在从资源文件(图像等)加载时不区分大小写,而设备则不区分大小写。
因此,当您的文件名为 myImage.png 时,模拟器会在您将其命名为 myImage.PNG 时加载它,但 iPhone 不会。
Aaah, this took me a long time. It was the old issue that the simulator is case-insensitive when loading from resource files (images, ...) and the device is not.
So when your file is named myImage.png, the simulator will load it when you name it myImage.PNG but iPhone will not.