Drawing UIImage into CurrentContext -


In my application I have used a UIImagePickerController to take a picture, and after this I can not attract it to the photo by using the UIImageView because I want to draw some lines from my finger.

At the end I have written this code in Draw Rect Methods:

- (zero) Direct: (CGRact) IMIS DREEN INVENT: RECTIT]; // Diazno Rattegolo del Tag CGContextRef myContext = UIGraphicsGetCurrentContext (); CGContextSetRGBStrokeColor (myContext, 0.5, 0.5, 0.5, 1.0); CGContextSetLineWidth (myContext, 3.0f); CGContextAddPath (myContext, PathTouch); CGContextStrokePath (myContext); }

and touchesMoved:

  - (zero) touchesMoved: (NSSet *) touches with an event: (UIEvent *) event {UITouch * touch = [Touches any object]; CGPoint Location INView = [Touch Location Invoice: Self]; Drag a connected sequence of the line segment to the CGPEightAdline [] = {// .... // some lines}; CGMutablePathRef newPath = CGPathCreateMutable (); CGPathRelease (pathTouches); PathTouches = CGPathCreateMutableCopy (newPath); CGPathRelease (Newpath); CGPathAddLines (Pathgun, Nouel, Adeline, Psychophé (Adelen) / Psychophag (Adlen [0]); [Self-setday display]; }  

What is the call to [self setNeedsDisplay]? Every time I run my finger, or is there a better way to do this?

I did this but stranded on another problem ... here is your solution ... < / P> imagePickerController: (UIImagePickerController *) Picker didFinishPickingImage: (UIImage *) Image Editing Info: (NSDictionary *) Editing Info {// Dismiss Image Selection, Hide Picker and // with Raised Image view showing image [picker dismissalModelView controller permission: Yes]; ImagePickerController.view.hidden = Yes; [Image Picture Controller Release]; ImageView.image = Image; ImageView.hidden = No; [ImageView setframe: CGRectMake (0, 20, 320, 396)]; [Window Laosvivio tofranot: image view]; }

Then

  - Increased touch (zero): (touchs the NSSE *) event: (UIEvent *) event {UITouch * touch = [Touches anyObject]; If ([touch] == EditImageView) {lastPoint = currentPoint; Last point = [touch the location in: self.view]; UIGraphicsBeginImageContext (EditImageView.frame.size); [EditImageView.image drawInRect: CGRectMake (0, 0, EditImageView.frame.size.width, EditImageView.frame.size.height)]; // sets a style for the finishing points of the lines drawn in a graphic reference CTX = UIGraphicsGetCurrentContext (); CGContextSetLineCap (ctx, kCGLineCapRound); // set the line width for a graphic reference CGContextSetLineWidth (ctx, 10.0); // Line color CGContextSetRGBStrokeColor (CTX, 1.0, 0.0, 0.0, 1.0) set; // Graphics Reference creates a new empty path in CGContextBeginPath (ctx); CGContextSetAllowsAntialiasing (ctx, true); // Start a new path to the point at which you specify CGContextMoveToPoint (ctx, currentPoint.x, currentPoint.y); // Adds the point provided to the straight line segment from the current point to CGContextAddLineToPoint (ctx, lastPoint.x, lastPoint.y); // Current path paints a line with CGContextStrokePath (ctx); EditImageView.image = UIGraphicsGetImageFromCurrentImageContext (); [Edit the image set set]; CGContextSaveGState (ctx); UIGraphicsEndImageContext (); CurrentPoint = Last Point; }} - (zero) touches: (NSSET *) touches the event: (UIEVENT *) event {UITouch * Touch = [touches an object]; If ([Touch view] == Edit imageview) {currentPoint = [touch on location: see itself]; }}  

Where CGPaint has been declared in the current point and final point header file.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -