2012-12-20 44 views
0

可能重複:
How to merge the perspective image(3D Transform)?如何在更改3D變換後合併兩張圖像?

我怎樣才能改變後合併兩個圖像的3D變換?我正在使用兩幅圖像

(i)背景圖像是正常圖像。 (ii)前景圖像改變3D變換。

現在我合併這兩個圖像。但不合並圖像,我使用下面的代碼。此代碼適用於沒有3D變換的情況。

UIGraphicsBeginImageContext(backgroundImageView.frame.size); 
CGContextRef ctx = UIGraphicsGetCurrentContext(); 
[imageView.layer renderInContext:ctx]; 
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 
UIImageWriteToSavedPhotosAlbum(newImage, nil, nil, nil); 
return newImage; 

我搜索了很多,但3D轉換圖像不支持圖層。

如何獲得此功能。我真的必須在我的應用程序中使用此功能任何想法,源代碼,建議,建議,隨時歡迎。請幫幫我。 enter image description here

+0

請不要問同樣的問題兩次。如果您第一次詢問時不喜歡答案,您可以不接受您在該問題上接受的答案。如果你需要更多的幫助,你可以提供你原來的問題的賞金。 –

+0

另外,看看[這個答案](http://stackoverflow.com/a/10677684/77567)。 –

+0

謝謝搶劫mayoff ... – Mani

回答

0

試試這個。

- (UIImage*)mergeImage:(UIImage*)first withImage:(UIImage*)second 
{ 
// get size of the first image 
CGImageRef firstImageRef = first.CGImage; 
CGFloat firstWidth = CGImageGetWidth(firstImageRef); 
CGFloat firstHeight = CGImageGetHeight(firstImageRef); 

// get size of the second image 
CGImageRef secondImageRef = second.CGImage; 
CGFloat secondWidth = CGImageGetWidth(secondImageRef); 
CGFloat secondHeight = CGImageGetHeight(secondImageRef); 

// build merged size 
CGSize mergedSize = CGSizeMake(MAX(firstWidth, secondWidth), MAX(firstHeight, secondHeight)); 

// capture image context ref 
UIGraphicsBeginImageContext(mergedSize); 

//Draw images onto the context 
[first drawInRect:CGRectMake(0, 0, firstWidth, firstHeight)]; 
[second drawInRect:CGRectMake(0, 0, secondWidth, secondHeight)]; 

// assign context to new UIImage 
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 

// end context 
UIGraphicsEndImageContext(); 

return newImage; 
} 
+0

謝謝HDdeveloper ...但是這個代碼只適用於3D變換。請任何其他的想法。 – Mani

相關問題