UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, -1);
有谁知道如果我在此函数中将比例因子设置为 -1 会发生什么?
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, -1);
_cacheImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[_cacheImage drawInRect:[self bounds]];
NSData *data = UIImageJPEGRepresentation(_cacheImage, 0);
NSLog(@"%i", data.length);
NSData *data = UIImage
如果我使用 -1,我将无法获得 UIImageJPEGRepresentation,但 drawInRect 可以正常工作。可能发生什么事? 另外,当使用 -1 时,我的应用程序使用的内存要少得多(在仪器中确认)
Does anyone know what happens if I set a -1 to the scale fator in this function?
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, -1);
_cacheImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[_cacheImage drawInRect:[self bounds]];
NSData *data = UIImageJPEGRepresentation(_cacheImage, 0);
NSLog(@"%i", data.length);
NSData *data = UIImage
If I use -1, I cannot get a UIImageJPEGRepresentation, but the drawInRect works ok. What could be going on?
Also whe using -1 my app uses a lot less memory (confirmed in instruments)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
负比例因子在文档中没有记录或定义的行为。
Negative scaling factors do not have a documented or defined behavior in the documentation.
从苹果论坛得到这个:
Got this from the apple forums: