UIView 中的 UIImage 尺寸太大
我在下面有一小部分代码:
- (UIImage *)imageFromView:(UIView *)myView{
if (UIGraphicsBeginImageContextWithOptions!=NULL)
{
UIGraphicsBeginImageContextWithOptions(myView.bounds.size,NO,0.0);
}
else
{
UIGraphicsBeginImageContext(myView.bounds.size);
}
[myView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return [[viewImage retain] autorelease];
}
从该函数获取 UIImage 后。我把它保存到照片库中。但图像尺寸太大。它与原始图像有很大不同。任何人都有解决方案。请帮我。 非常感谢大家。
I have small section of code below:
- (UIImage *)imageFromView:(UIView *)myView{
if (UIGraphicsBeginImageContextWithOptions!=NULL)
{
UIGraphicsBeginImageContextWithOptions(myView.bounds.size,NO,0.0);
}
else
{
UIGraphicsBeginImageContext(myView.bounds.size);
}
[myView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return [[viewImage retain] autorelease];
}
After getting UIImage from this function. I save it into photo library. But the size of image is too big. It's pretty different from original image. Anyone has solution for this. Please help me.
Thank you all so much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NSLog()
当前myView.Bounds.size
并检查哪个语句被调用。您的图像有多大?应该有多大?
NSLog()
the currentmyView.Bounds.size
and also check which statement gets called.How big is your image and how big should it be?