如何在iOS中调整图像大小? [英] How to resize an image in iOS?

查看:133
本文介绍了如何在iOS中调整图像大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我想将图片发送到网络服务。但我想将用户选择的任何图像调整为75 x 75并将其发送到Web服务。如何将此图像调整为75 x 75

hi I want to send an image to a web service. But I want to resize user selected any image into 75 x 75 and send it to web service. How can I resize this image into 75 x 75

谢谢

推荐答案

尝试实现以下代码。它可能对您有所帮助:

Try to implement the code below. It may be helpful for you:

    CGRect rect = CGRectMake(0,0,75,75);
    UIGraphicsBeginImageContext( rect.size );
    [yourCurrentOriginalImage drawInRect:rect];
    UIImage *picture1 = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    NSData *imageData = UIImagePNGRepresentation(picture1);
    UIImage *img=[UIImage imageWithData:imageData];

这篇关于如何在iOS中调整图像大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆