2012-02-14 57 views
0

按照我的標題,我有一張2張圖片,我將其保存爲一張圖片。如何保存兩張圖片,允許其中一張圖片旋轉,縮放並移動

其中一張照片允許用戶進行旋轉,縮放和移動等姿勢。

我該如何保存用戶移動和旋轉的圖片?


screen shot of the phone         saved image 

iphone screenSaved image

下面的代碼是從稱爲How to combine/ merge 2 images into 1

UIImage *image = nil; 

     CGSize newImageSize = CGSizeMake(cropImage.frame.size.width, cropImage.frame.size.height); 
     if (UIGraphicsBeginImageContextWithOptions != NULL) { 
      UIGraphicsBeginImageContextWithOptions(newImageSize, NO, [[UIScreen mainScreen] scale]); 
     } else { 
      UIGraphicsBeginImageContext(newImageSize); 
     } 

    // Draw image1 
    [maskImage.image drawInRect:CGRectMake(0,0, maskImage.frame.size.width,maskImage.frame.size.height)]; 
    // Draw image2 
    [cropImage.image drawInRect:CGRectMake(cropImage.frame.origin.x, cropImage.frame.origin.y, cropImage.frame.size.width, cropImage.frame.size.height)]; 

    image = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 

    return image; 

回答

2

嘗試這段代碼

//Hide your views here like save button 
    CGRect screenRect = [[UIScreen mainScreen] bounds]; 
    UIGraphicsBeginImageContext(screenRect.size); 
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; 
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
    UIImageWriteToSavedPhotosAlbum(viewImage, self, nil, nil); 
//Show again your hidden views here like save button 
+0

你是偉大的......謝謝你這麼多... – IKKA 2014-11-01 12:48:45

相關問題