Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.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 从变换后的imageview中绘制图像_Iphone_Ios_Objective C_Core Graphics_Cgcontext - Fatal编程技术网

Iphone 从变换后的imageview中绘制图像

Iphone 从变换后的imageview中绘制图像,iphone,ios,objective-c,core-graphics,cgcontext,Iphone,Ios,Objective C,Core Graphics,Cgcontext,我想从变换后的uiimageview中绘制图像-请参阅左侧图像 Dragview=UIImageView,可以使用一些控件进行旋转或缩放,我需要在同一位置绘制转换后的图像 我面临转换问题(CGContextConcatCTM) 如果需要,它会给出所需的输出 CGAffineTransform = CGAffineTransformIdentity 但我用同样的变换在输出图像上得到了错误的原点 下面是我绘制图像的代码,与原始imageview相同 UIGraphicsBeginImageCont

我想从变换后的
uiimageview
中绘制图像-请参阅左侧图像

Dragview=UIImageView,可以使用一些控件进行旋转或缩放,我需要在同一位置绘制转换后的图像

我面临转换问题(
CGContextConcatCTM

如果需要,它会给出所需的输出

CGAffineTransform = CGAffineTransformIdentity
但我用同样的变换在输出图像上得到了错误的原点

下面是我绘制图像的代码,与原始imageview相同

UIGraphicsBeginImageContext(CGSizeMake(1024, 768));
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextConcatCTM(context, dragView.originalTransform);  
UIImage *curImage1 = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
试试这个:

UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];

UIImage * img = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

不,我已经尝试过了,这将在点(0,0)处绘制,没有任何转换。您应该解释此代码的作用,以便OP(和其他用户)能够理解发生了什么。UIGraphicsBeginImageContextWithOptions使用指定的选项创建基于位图的图形上下文。视图是要捕获为图像的视图。。。第一个参数是大小,第二个是不透明,第三个是比例!要应用于位图的比例因子。如果指定的值为0.0,则比例因子将设置为设备主屏幕的比例因子。然后view.layer RenderContext:UIGraphicsGetCurrentContext()将基本上返回视图的图形上下文。。。。最后我们把所有的东西都保存在一个图像中。