[英]Specifying scale for UIImage loaded from NSData
My app stores images as NSData objects. 我的应用程序将图像存储为NSData对象。 However, when these are loaded on an iPhone 4, they are displayed at double the size because the default scale factor is 1. I have 2 questions I would appreciate help with please:
但是,当将它们加载到iPhone 4上时,它们会以两倍大小显示,因为默认比例因子是1。我有2个问题,请提供帮助:
Is there any way to set the scale of the UIImage without using initWithCGImage:scale:orientation:
有没有办法设置UIImage的比例而不使用
initWithCGImage:scale:orientation:
If the answer to 1 is no, what is the most efficient way to load the NSData into a UIImage using the method above? 如果对1的回答为否,那么使用上述方法将NSData加载到UIImage的最有效方法是什么? At present it seems I will have to create a UIImage from the NSData and then create another UIImage using the method noted in 1 above.
目前看来,我将不得不从NSData创建一个UIImage,然后使用上面1中提到的方法创建另一个UIImage。
Thank you. 谢谢。
UIImage
is immutable, so I guess there is no way to do so without hacking. UIImage
是不可变的,因此我想如果没有黑客就无法做到这一点。 UIImage
is just a wrapper of CGImage
, so I think using initWithCGImage:
as you describe won't have any noticeable performance impact. UIImage
只是CGImage
的包装,因此我认为使用initWithCGImage:
正如您所描述的,不会对性能产生任何明显的影响。 If you really worry about that, you can load it to CGImageRef
first. CGImageRef
其加载到CGImageRef
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.