2
두 개의 이미지가 있습니다. 하나는 가장자리/테두리가 다른 투명한 마스크이고 다른 하나는 실제 이미지입니다. 둘 다 병합하고 싶습니다.iOS의 다른 실제 이미지로 투명한 이미지 마스킹
- (UIImage*) maskImage:(UIImage *)image withMask:(UIImage *)maskImage {
// create a bitmap graphics context the size of the image
CGFloat dim = MIN(image.size.width, image.size.height);
CGSize size = CGSizeMake(dim, dim);
UIGraphicsBeginImageContextWithOptions(size, NO, .0);
UIBezierPath *bezierPath = [UIBezierPath bezierPathWithOvalInRect:(CGRect){ CGPointZero, size }];
[bezierPath fill];
[bezierPath addClip];
CGPoint offset = CGPointMake((dim - image.size.width) * 0.5, (dim - image.size.height) * 0.5);
[image drawInRect:(CGRect){ offset, image.size }];
UIImage *ret = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return ret;
}
결과 : 결과 이미지에서
, 국경
나는 이미지를 마스크하고 결합하기 위하여 다음 코드를 사용했다 마스크로 사용 된 이미지에이 누락되었습니다. 누군가 이걸로 나를 도울 수 있습니까?
는핵심 기능은) 당신의 (예를 들어,이에
를 요약된다 :
당신은 결코 당신의 컨텍스트에 마스크 이미지를 그리거나 당신의 방법에 어떤 식 으로든 maskImage를 사용하지 마십시오 ... –
달성 할 수있는 방법이 있습니다. 나는 어떻게해야할지 모른다. 나는 어딘가에서 코드를 가져왔다. – user3772344