[英]UIImage picker changes image size
I have an application in which I am scanning text from a picture. 我有一个应用程序,正在其中扫描图片中的文本。 I am using OCR. 我正在使用OCR。 Now the problem is my source image size is 3024*3024. 现在的问题是我的源图像大小是3024 * 3024。 I have copied the image into iPhone 6 Simulator in Xcode. 我已将图像复制到Xcode的iPhone 6模拟器中。 Now when I uploaded the image using uiimagepicker controller the image was resized to 748*748 and its quality is not same. 现在,当我使用uiimagepicker控制器上传图像时,图像已调整为748 * 748,其质量也不相同。
When I tried to increase image size the image's quality is not the same. 当我尝试增加图像尺寸时,图像质量不一样。 What I need is image in its actual size and quality/resolution should not change. 我需要的是图像的实际大小,质量/分辨率不应改变。
try this code to resize image 尝试使用此代码调整图像大小
- (UIImage*)imageWithImage:(UIImage*)img scaledToSize:(CGSize)newSize;{
UIGraphicsBeginImageContext( newSize );
[img drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
UIImage* newImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImg;
}
and For the compression of images 和用于图像压缩
NSData *dataForJPEGFile = UIImageJPEGRepresentation(theImage, 0.6);
Thanks 谢谢
Did you set the qualityType property of your UIImagePickerController to UIImagePickerControllerQualityTypeHigh
? 您是否将UIImagePickerController的qualityType属性设置为UIImagePickerControllerQualityTypeHigh
? The default is medium. 默认值为中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.