0
这是我的第一个月,在Objective-C,我试图绘制一个UIImage的(ImageA)上的另一个图像(背景图像)顶部Objective-c - 如何将图像绘制为四边形?
ImageA四边形
我已经试过到目前为止是3D转换含ImageA与 https://stackoverflow.com/a/18606029/864513
的帮助下的UIImageView再取转化视图的快照
- (UIImage *)snapshot:(UIView *)view
size:(CGSize)size
{
UIImage *viewImage = nil;
@autoreleasepool {
UIGraphicsBeginImageContext(size);
BOOL success = [view drawViewHierarchyInRect:(CGRect){CGPointZero, size} afterScreenUpdates:YES];
viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
if (!success || !viewImage) {
return nil;
}
}
return viewImage;
}
然后在图像上下文中的矩形中绘制快照图像以及背景图片
CGRect offsetRect = CGRectMake(0, 0, fileSize.width, fileSize.height);
UIGraphicsBeginImageContext(fileSize);
[BackgroundImage drawInRect:offsetRect];
[ImageA drawInRect:offsetRect];
UIImage *endImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
这种方法效果很好,但在循环中使用时,创建GIF
。它导致很多内存泄漏和崩溃在低内存设备!
CGImageDestinationAddImage(destination, [endImage CGImage], (__bridge CFDictionaryRef)frameProperties);
在Android中有一个叫做drawBitmapMesh
的函数,它通过网格绘制位图。有没有什么办法可以通过objective-c中的网格来绘制。或者如果你知道一个更好的方法来解决我的问题,我会永远感激。 谢谢
谢谢,我已经试过了,但结果是粗略的,而imageA没有覆盖整个区域的预期。 –
最后,让它与Perspective Transform一起工作! –