자르기 기능을 구현 중이며 자르기 사각형이 변환 된 이미지보기 안에 완전히 포함되어 있는지 테스트하는 방법을 알아 내려고하고 있습니다. 즉, 이미지의 잘린 부분에 공백이 없어야한다.CGRect가 다른 (변형 된) 사각형 안에 포함되어 있는지 확인하십시오.
비슷한 구성 (아래 참조)을 구현하는 https://github.com/heitorfr/ios-image-editor이이 구성 요소에서 구현 된 동작을 복사하려고했지만 상황에 따라 작동하지 않습니다.
- (void)checkBoundsWithTransform:(CGAffineTransform)transform
{
CGRect r1 = [self boundingBoxForRect:self.preview.cropRect
rotatedByRadians:[self imageRotation]];
Rectangle r2 = [self applyTransform:transform
toRect:self.preview.initialImageFrame];
CGAffineTransform t =
CGAffineTransformMakeTranslation(CGRectGetMidX(self.preview.cropRect),
CGRectGetMidY(self.preview.cropRect));
t = CGAffineTransformRotate(t, -[self imageRotation]);
t = CGAffineTransformTranslate(t,
-CGRectGetMidX(self.preview.cropRect), -
CGRectGetMidY(self.preview.cropRect));
Rectangle r3 = [self applyTransform:t toRectangle:r2];
if(CGRectContainsRect([self CGRectFromRectangle:r3],r1)) {
self.validTransform = transform;
}
}
중복 가능성 (http://stackoverflow.com/questions/8981931/cgrectcontainsrect-not-working) – Palpatim
이는, CGRectContainsRect() 해결 될 수있는 문제가 아니다 이미지 뷰의 변형 된 사각형을 회전시킬 수 있습니다. 즉, CGRect – Niels