2013-01-21 50 views
2

後在一個圖像視圖中保存兩個圖像視圖**我有兩個圖像視圖一個用於背景,另一個用於前景,我用前景imageview.for擦除功能我這樣做是因爲我沒有想擦除擦除時的背景圖像。我做得很好。現在我想保存那個圖像(背景+前景),我需要通過郵件來擦掉它。有可能嗎? **如何在繪製iphone

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 

    if (doodlemode==YES){ 

    UITouch *touch = [touches anyObject]; 

    previousPoint2 = previousPoint1; 
    previousPoint1 = [touch previousLocationInView:self.view]; 
    currentPoint = [touch locationInView:self.view]; 


    // calculate mid point 
    CGPoint mid1 = midPoint(previousPoint1, previousPoint2); 
    CGPoint mid2 = midPoint(currentPoint, previousPoint1); 

    UIGraphicsBeginImageContext(imageDoodle.frame.size); 

    CGContextRef context = UIGraphicsGetCurrentContext(); 


    [imgView.image drawInRect:CGRectMake(0, 0, imageDoodle.frame.size.width,  

    imageDoodle.frame.size.height)]; 

    CGContextMoveToPoint(context, mid1.x, mid1.y); 

    CGContextAddQuadCurveToPoint(context, previousPoint1.x, previousPoint1.y, mid2.x, mid2.y); 

    CGContextSetLineCap(context, kCGLineCapRound); 

    [imgView.layer renderInContext:UIGraphicsGetCurrentContext()]; 

    //this is for erase 
    if(IsErase) 
    { 
    CGContextSetBlendMode(context,kCGBlendModeClear); 
    } 
    //make a strok color 
    else 
    { 
    CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), redvalue, greenvalue, bluevalue, 

    1.0); 
    } 

    CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 8.0); 
    //size of stroke 

    CGContextStrokePath(UIGraphicsGetCurrentContext()); 


    imgView.image = UIGraphicsGetImageFromCurrentImageContext(); 


    UIGraphicsEndImageContext(); 

    } 

} 
    -(IBAction)sharePrint{ 
    //Compose email with activity sheet attached 

    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; 

    picker.mailComposeDelegate = self; 

    [UIImage imageNamed:@"feedback.png"]]]; 

    *//here i nedd to sand that. Image how can i?* 

    NSData *imageData = UIImagePNGRepresentation(imgView.image); 

    [picker addAttachmentData:imageData mimeType:@"image/png" fileName:@"shared.png"]; 

    //Show Mail view with composed email 

    [self presentModalViewController:picker animated:YES]; 

    } 
+1

幫助我任何一個.. – virantporwal

回答

2
 

- (void) someMethod { 
    UIImage *newImage = [self captureScreen]; 
    IBbtn1.hidden = FALSE; 
    IBbtn2.hidden = FALSE; 
} 

- (UIImage *) captureScreen { 

    IBbtn1.hidden = TRUE; 
    IBbtn2.hidden = TRUE; 

    CGRect rect = [wrapperView bounds]; 
    UIGraphicsBeginImageContext(rect.size); 
    CGContextRef context = UIGraphicsGetCurrentContext(); 
    [wrapperView.layer renderInContext:context]; 
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
    return img; 
} 

+0

ok好的thanx ..... – virantporwal

0

您可以捕獲具有背景和前景圖像的視圖,並將其存儲爲sinalge圖像,並可以郵寄該捕獲的圖像。

+1

但我的背景圖片也是多變.... – virantporwal

+0

一旦你同時編輯,你可以捕捉視圖(其爲具有前景和背景圖像),並將其保存爲圖像 – spaleja

+0

我如何捕獲該視圖給我一個例子。 – virantporwal