2012-03-30 60 views
0

我有一個應用程序,允許在各種背景顏色上書寫。當我調用該方法來捕獲寫入照片庫時,我得到了寫作,但沒有任何背景色。ipad應用程序發送圖像到照片庫不捕獲背景

我可以利用一些幫助找出爲什麼..

我畫的背景顏色足夠簡單:

drawImage.backgroundColor = [UIColor someColor]; 

的drawImage被定義爲UIImageView

我寫的drawImage OK:

UIGraphicsBeginImageContext(self.view.frame.size); 
    [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
    CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); 
    CGContextSetLineWidth(UIGraphicsGetCurrentContext(), brush); 
    CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), red, green, blue, 1.0); 
    CGContextBeginPath(UIGraphicsGetCurrentContext()); 
    CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); 
    CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y); 
    CGContextStrokePath(UIGraphicsGetCurrentContext()); 
    drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); 
    savedImage.image = drawImage.image; 
    UIGraphicsEndImageContext(); 

,並寫入到照片庫就像下面這樣:

UIImageWriteToSavedPhotosAlbum(drawImage.image, self, nil, nil); 

我將不勝感激任何意見。

謝謝

回答

0

我得到了Apple Dev的幫助。論壇上,所以我想我會後在這裏幫助別人(以及更多評論):

CGImageRef UIGetScreenImage(void); 

然後

-(void)captureToPhotoAlbum { 
    NSLog(@"%s", __FUNCTION__); 
    // Get image to save 
    CGImageRef screen = UIGetScreenImage(); 
    UIImage *img = [UIImage imageWithCGImage:screen]; 

    // Image cropping 
    CGImageRef imageRef = CGImageCreateWithImageInRect([img CGImage], CGRectMake(0.0f, 70.0f, 768.0f, 768.0f)); 
    UIImage *img2Save = [UIImage imageWithCGImage:imageRef]; 
    CGImageRelease(imageRef); 

    // Request to save the image to camera roll 
    UIImageWriteToSavedPhotosAlbum(img2Save, self, nil, nil); 

} 
相關問題