좋아요. 검색을 끝내고 필요한 답을 찾을 수없는 것 같습니다. :-(변환 후 UIImageWriteToSavedPhotosAlbum을 사용하여 이미지를 저장하는 방법
여기 내가하고있는 일과 내가해야 할 일이있다. 나는 UIPanGestureRecognizer, UIRotationGestureRecognizer 및 UIPinchGestureRecognizer를 사용하여 transfrom 할 수있는 UIImageView를 가지고있다. 문제는 시간이되면된다. 내 포토 앨범에 그 transfomations을 저장합니다. 결과는 내가 기대하고 있지 무엇인가. 지금까지 여기 내가 사용하고있는 코드입니다 (알은 - 수 - 그것은 매우 불완전한) I 저장할 수 있어요이 방법에서
-(IBAction)saveface:(id)sender
{
static int kMaxResolution = 640;
CGImageRef imgRef = face.image.CGImage;
CGFloat width = CGImageGetWidth(imgRef);
CGFloat height = CGImageGetHeight(imgRef);
CGRect bounds = CGRectMake(0, 0, width, height);
if (width > kMaxResolution || height > kMaxResolution) {
CGFloat ratio = width/height;
if (ratio > 1) {
bounds.size.width = kMaxResolution;
bounds.size.height = bounds.size.width/ratio;
} else {
bounds.size.height = kMaxResolution;
bounds.size.width = bounds.size.height * ratio;
}
}
UIGraphicsBeginImageContext(bounds.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextScaleCTM(context, 1, -1);
CGContextTranslateCTM(context, 0, -height);
NSLog(@"SAVE TX:%f TY:%f A:%f B:%f C:%f D:%f", face.transform.tx, face.transform.ty, face.transform.a,face.transform.b,face.transform.c,face.transform.d);
CGFloat x = face.transform.tx;
CGFloat y = face.transform.ty;
CGContextTranslateCTM (context, x,-y);
CGContextConcatCTM(context, face.transform);
CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, width, height), imgRef);
UIImage *imageCopy = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(imageCopy, self, nil, nil);
}
그러나 좌표는 벗어났습니다. 내가했던 모든 스케일링을 볼 수 있습니다. 내 회전을 봅니다. 그러나 뒤쪽으로 보이고 팬이 꺼지는 것 같습니다.
코드는 모두 잘못되었으며 나에게있어 잘못된 점을 파악할 수 없습니다. 나는 Objective-C에 익숙하지 않다. 그리고 나는 이전에 Quartz 2D를 사용 해본 적이 없다. 그리고 변환 행렬에 대한 나의 이해는 제한적이다. 나는이 컨텍스트를 적용하지 않고 이미지를 바로 저장하려고 시도 할 때 내 변환이 이미지 데이터 자체에 있지 않다는 것을 이해한다. 그러니 제발 누가 나를 똑바로 세울 수 있니?