C++ 是否有一个开源框架来补充PNG?应该使用Xcode
以下是要求:C++ 是否有一个开源框架来补充PNG?应该使用Xcode,c++,ios,c,xcode,image-processing,C++,Ios,C,Xcode,Image Processing,以下是要求: 输入是PNG a和PNG B,输出应该是PNG a减去PNG B(在PNG a上用PNG B的形状挖一个洞)。我认为这应该是一个取长补短的行动,我需要一些库或框架来做到这一点 此框架应与Xcode配合使用,也可用于各种plantforms(MAC/iOS/Win…等)。所以我认为应该用C/C++来实现 任何例子或代码都应该是我的问题的主要补充。。。我真的不知道该怎么做:( 有什么建议吗?您可以尝试以下代码: UIImage *imgA = [UIImage imageNamed:@
UIImage *imgA = [UIImage imageNamed:@"pngA.png"];
UIImage *imgB = [UIImage imageNamed:@"pngB.png"];
UIGraphicsBeginImageContextWithOptions(imgA.size, NO, imgA.scale);
[imgA drawAtPoint:CGPointZero];
[imgB drawAtPoint:CGPointZero blendMode:kCGBlendModeDestinationOut alpha:1.0f];
UIImage *resultImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
您可以使用mask来执行此操作 请尝试以下代码:
- (UIImage*) maskImage:(UIImage *)image withMask:(UIImage *)maskImage {
CGImageRef maskRef = maskImage.CGImage;
CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef),
CGImageGetHeight(maskRef),
CGImageGetBitsPerComponent(maskRef),
CGImageGetBitsPerPixel(maskRef),
CGImageGetBytesPerRow(maskRef),
CGImageGetDataProvider(maskRef), NULL, false);
CGImageRef masked = CGImageCreateWithMask([image CGImage], mask);
return [UIImage imageWithCGImage:masked];
}
这是一个很好的解决方案,但我需要一个C/C++实现,以便跨平台使用。无论如何,感谢您的快速回复:)