Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Save and Load Drawing lines iphone SDK

Tags:

ios

iphone

I want to Save Drawing lines permanently and load Drawing lines saved from Project resource...!

Now i am get x and y position on touch move event.i want to save the x and y position in local resource on a project,But i am not experience in ios for no idea...!

And Load Saved x and y position from project local resource saved file..!

I want to Save Drawing lines Below like this:

enter image description here

Please any one Help me with Greatly appreciated...!

Thanks...!

like image 956
Dinesh Avatar asked Apr 12 '12 08:04

Dinesh


1 Answers

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

    if(!mouseSwiped) {
        CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeClear);
        UIGraphicsBeginImageContext(ivBack.frame.size);
        [drawImage.image drawInRect:CGRectMake(0,0, self.ivBack.frame.size.width,self.ivBack.frame.size.height)];
        CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
        CGContextSetLineWidth(UIGraphicsGetCurrentContext(), line);
        CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(), [pickColor CGColor]);
        CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
        CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
        CGContextStrokePath(UIGraphicsGetCurrentContext());
        CGContextFlush(UIGraphicsGetCurrentContext());

 NSData *dataImage=UIImagePNGRepresentation(UIGraphicsGetImageFromCurrentImageContext());
        [dataImage writeToFile:[self SavedImage:(@"1.png")] atomically:YES];
        drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
    }
}

that will defenatly solve ur question

like image 137
iBhavik Avatar answered Oct 11 '22 14:10

iBhavik