2009-08-14 4 views
0

하나 이상의 이미지를 배경 이미지와 함께 하나의 이미지로 저장 한 다음 저장하려고합니다. 이미지를 평평하게하는 방법을 알았지 만 배경 위에 추가 한 이미지가 평평하게 보이지 않을 때 정확한 위치에 나타나지 않습니다. 다른 배경 이미지 크기로 다른 위치에 나타나는 것처럼 보입니다.Iphone SDK의 이미지 병합

UIGraphicsBeginImageContext(backGroundImage.image.size); 
CGContextRef ctx = UIGraphicsGetCurrentContext(); 
//CGRect area= [self bounds]; 
CGRect area = CGRectMake(0, 0, backGroundImage.image.size.width, backGroundImage.image.size.height); 
CGRect area2= CGRectMake(testImage.frame.origin.x, testImage.frame.origin.y, testImage.frame.size.width, testImage.frame.size.height); 
//Need to flip images to the correct orientation 
CGContextTranslateCTM(ctx, 0, area.size.height); 
CGContextScaleCTM(ctx, 1, -1); 
CGContextSetBlendMode(ctx, kCGBlendModeNormal); 

//Drawing background first 
CGContextDrawImage(ctx, area, backGroundImage.image.CGImage); 

//Draw other images on top 
//[[AccessoryManager sharedManager] SaveImages:ctx]; 
CGContextDrawImage(ctx, area2, testImage.image.CGImage); 

//Creating one single image from context. 
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 

UIGraphicsEndImageContext(); 
UIImageWriteToSavedPhotosAlbum(newImage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil); 

답변

1

영역 2는 상당히 의심스럽고 번호가 맞는지 확인할 수 있습니다. 또한, 거기에 프레임 속성을 보았다. UIImageView와 UIImage를 혼합하고 있습니까? testImage.image의 자체 size 속성을 사용하려고 할 수 있습니다.