我在从转换后的 UIImageView 生成高分辨率图像时遇到了麻烦。我有一个画布视图,其中包含由用户手指转换的多个视图。所以我尝试根据它们的变换来渲染这些视图的图像。这是我用于视图的代码快照。
CGSize canvasSize = CGSizeMake(HIRES_WIDTH, HIRES_WIDTH);
CGAffineTransform scaleTransform = CGAffineTransformMakeScale(HIRES_WIDTH / canvasView.frame.size.width, HIRES_WIDTH / canvasView.frame.size.width);
UIGraphicsBeginImageContext(canvasSize);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGPoint center = imageView.center;
CGSize size = imageView.bounds.size;
CGRect frame = CGRectMake(center.x - size.width, center.y - size.height, size.width, size.height);
CGAffineTransform transform = CGAffineTransformIdentity;
transform = CGAffineTransformTranslate(transform, size.width / 2, size.height / 2);
transform = CGAffineTransformConcat(transform, photoImageView.transform);
transform = CGAffineTransformConcat(transform, scaleTransform);
CGContextConcatCTM(context, transform);
[photoImageView.image drawInRect:frame];
CGContextRestoreGState(context);
UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
但是我在最终图像上得到了偏移差异。任何意见,将不胜感激。
谢谢。