Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 裁剪图像后图像是否模糊?_Iphone_Ios_Ipad - Fatal编程技术网

Iphone 裁剪图像后图像是否模糊?

Iphone 裁剪图像后图像是否模糊?,iphone,ios,ipad,Iphone,Ios,Ipad,我有一个应用程序,其中我正在裁剪从相机拍摄的图像。一切都进行得很顺利。但裁剪后的图像似乎模糊和拉伸 CGRect rect = CGRectMake(20,40,280,200); UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); // translated rectangle for drawing sub image CGRect drawRect =

我有一个应用程序,其中我正在裁剪从相机拍摄的图像。一切都进行得很顺利。但裁剪后的图像似乎模糊和拉伸

CGRect rect = CGRectMake(20,40,280,200);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();

// translated rectangle for drawing sub image 
CGRect drawRect = CGRectMake(-rect.origin.x, -rect.origin.y,280,200);

// clip to the bounds of the image context
// not strictly necessary as it will get clipped anyway?
CGContextClipToRect(context, CGRectMake(0, 0, rect.size.width, rect.size.height));

// draw image
[image drawInRect:drawRect];

// grab image
UIImage* croppedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGSize size = [croppedImage size];
NSLog(@" = %@",NSStringFromCGSize(size));
NSData* pictureData = UIImagePNGRepresentation(croppedImage);
有人能帮我找出哪里出了问题吗?

试着替换一下

UIGraphicsBeginImageContext(rect.size);


要解释视网膜

你是指这个还是这个?你能提供一个屏幕截图吗?请检查这个:-但它给了我两倍大小的图像。例如(560400)图像。
UIGraphicsBeginImageContextWithOptions(rect.size, NO, [[UIScreen mainScreen] scale]);