Answer the question
In order to leave comments, you need to log in
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/>
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];
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question