【问题标题】:image is blurred after cropping the image?裁剪图像后图像模糊?
【发布时间】:2013-04-09 14:37:54
【问题描述】:

我有一个应用程序,我正在裁剪从相机拍摄的图像。一切正常。但裁剪后图像似乎变得模糊和拉伸。

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);

谁能帮我找出我哪里出错了?

【问题讨论】:

标签: iphone ios ipad


【解决方案1】:

尝试替换

UIGraphicsBeginImageContext(rect.size);

UIGraphicsBeginImageContextWithOptions(rect.size, NO, [[UIScreen mainScreen] scale]);

考虑视网膜

【讨论】:

  • 但它给了我双倍尺寸的图像。例如 (560,400) 图像。
猜你喜欢
  • 2017-01-14
  • 1970-01-01
  • 2013-08-19
  • 1970-01-01
  • 1970-01-01
  • 2017-05-22
  • 1970-01-01
  • 2023-03-22
  • 1970-01-01
相关资源
最近更新 更多