请参考下面附图,如何在不使用遮蔽的情况下在黑色边缘内进行涂漆[例如 - 如果我们想要在盖子内部绘制,我们需要使用刷子工具填充盖子].
我们已经使用泛洪填充算法实现了桶工具.
参考[图4]这种类型的图纸是错误的,所以我们只需要在黑色边缘内绘制参考[图像2]和[图像3].
我们需要在iOS SDK中实现这一点,
我已经尝试过这两种方式 -
我记录了特定区域的坐标,它滞后太多,内存泄漏就在那里.这不是一个好方法
我必须在后台使用桶工具(泛洪填充算法)填充特定区域,然后尝试匹配触摸点的颜色.它也没有提供完美的输出.
[图片1]
[图片2]
[图3]
[图片4]
我有一个UIImage作为截图生成.我正在使用以下代码添加此对象:
self.view.backgroundColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.0];
drawImage.backgroundColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.0];
UIGraphicsBeginImageContext(self.view.bounds.size);
[drawImage.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGImageRef rawImageRef=viewImage.CGImage;
const float colorMasking[6] = {255,255,255,255,0,0};
CGImageCreateWithMaskingColors(rawImageRef, colorMasking);
UIImage *newImage = [UIImage imageWithCGImage:rawImageRef];
Run Code Online (Sandbox Code Playgroud)
然而,我的图像只变白了,我想通过使用CGImageCreateMaskingColors让图像在白色的地方透明.
希望有人可以帮助我.
image ×1
ios ×1
iphone ×1
masking ×1
objective-c ×1
opengl-es ×1
swift ×1
transparent ×1
uiimage ×1