我有一个 screenshot一个 UIWebView 的页面,页面上的所有图像都有一个鲜红色的 eclipse 刻边框。我想知道如何根据边框将此屏幕截图切割成更小的图像。例如,谷歌页面将只有 Logo 和小的位置指示器。是否有任何我需要研究的图像分析库?任何对此的见解将不胜感激。
编辑:边框可以更改为 eclipse 刻或实心以及所需的任何颜色。
最佳答案
你可以尝试这段代码,因为我也在为从 UIWebview 裁剪图像做同样的事情:
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGRect rect = **your cropping CGREct**;
CGImageRef imageRef = CGImageCreateWithImageInRect([viewImage CGImage], rect);
UIImage *imgRect = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
希望对你有帮助
关于iphone - Objective-C - 基于 eclipse 刻线边界切割图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18798093/