iphone - 从变换后的 ImageView 绘制图像

标签 iphone ios objective-c core-graphics cgcontext

我想从转换后的 uiimageview 中绘制图像 - 引用左侧图像,

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

我遇到转换问题(CGContextConcatCTM),

它给出所需的输出如果

CGAffineTransform = CGAffineTransformIdentity

但我在具有相同变换的输出图像上得到了错误的原点

下面是我用来绘制与原始 ImageView 相同的图像的代码

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

Refer below image

最佳答案

试试这个:

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

UIImage * img = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

关于iphone - 从变换后的 ImageView 绘制图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17065600/

相关文章:

iphone - 如何在隐藏控件时仅捕获 MPMoviePlayerController View 上的单击/点击?

javascript - 网站工作,但不是在 iphone 上。 XMLHttpRequest() 错误

ios - UICollectionView 崩溃

ios - 优化 NSRegularExpression 性能

c++ - 从 C++ 轮询 FSEvents

iphone - 配置 UItableView 不在 iPhone 上滚动

使用新的 ios sdk 5.0 屏幕锁定后 iPhone 应用程序网络连接断开

ios - 点击 userLocation 的标题

objective-c - 将 NSNumber (double) 值转换为时间

asp.net - 基于iPhone Phonegap的应用程序加载由Componentone组成的外部网站