A
A
AndreyIvanoff2011-05-20 18:29:49
iOS
AndreyIvanoff, 2011-05-20 18:29:49

iPhone programming. How to draw an image on a context?

Hello habrovchane, please help.
In the course of a long search, I could not solve this problem.
The essence of the problem is this: in real time, a picture comes from the iPhone camera:

CGContextRef newContext = CGBitmapContextCreate(baseAddress, width, height, 8, bytesPerRow, colorSpace, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst);<br/>
 CGColorSpaceRelease(colorSpace);<br/>
 <br/>
 CGImageRef newImage = CGBitmapContextCreateImage(newContext); <br/>
 UIImage *image= [UIImage imageWithCGImage:newImage scale:1 orientation:UIImageOrientationRight];<br/>
 CGImageRelease(newImage);<br/>

The incoming image is the image variable.
This image is then analyzed and 5 lines are drawn on it:
CGPoint * lineArray = /*Метод возвращающий массив из точек, по которым строятся линии*/<br/>
CGContextAddLines(newContext, lineArray, 5);<br/>
<br/>
CGContextStrokePath(newContext);<br/>
<br/>
newImage = CGBitmapContextCreateImage(newContext); <br/>
image = [UIImage imageWithCGImage:newImage scale:1 orientation:UIImageOrientationRight];<br/>
<br/>
CGImageRelease(newImage);<br/>
CGContextRelease(newContext);<br/>
<br/>
[self.imageView performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:NO];

And everything starts all over again.
Question: How can I draw not just lines, but, for example, a picture, or, more difficultly, a gif-animation. Perhaps the question is too naive.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question