cgcontext

CGContext transparency problem

南笙酒味 提交于 2019-12-24 19:07:12
问题 I have an UIView which has white background color set. I have set the blending mode of the CGContext of the UIView as 'kCGBlendModeCopy'. Then, 1. Draw an UIImage in that CGContext 2. Draw a path with alpha as 0 in that context. The transparent area covered by the path appears in black whereas my expected output was that it should be UIView's background color (i.e. white). Does anyone knows what is the problem here? Thanks in advance, Regards, Deepa 回答1: There is no problem here and hence no

UITableViewCells invalid context trying to draw

送分小仙女□ 提交于 2019-12-24 09:38:08
问题 I am trying to draw a checkbox triangle in a UITableViewCell. In the Data Source protocol method -tableView:cellForRowAtIndexPath: I have added the following in the code bloc which asks if the cell is nil: CGContextRef context = UIGraphicsGetCurrentContext(); CGContextBeginPath(context); CGContextMoveToPoint(context, 75,10); CGContextAddLineToPoint(context, 10, 150); CGContextAddLineToPoint(context, 160, 150); CGContextClosePath(context); [[UIColor blackColor] setStroke]; CGContextStrokePath

Why does my Coregraphics drawingcode cause lag?

丶灬走出姿态 提交于 2019-12-24 07:38:23
问题 I'm working on an drawing app for iPhone. It works fine for like 5 seconds in the iPhone simulator but as more I draw it gets more laggy. When I test it on the device it gets even more laggy and I can't even draw a simple tree. When I check how high percent the processor is running at in xcode it usually go between 97-100%. Is there any way to fix this? (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; currentPoint = [touch locationInView

Crop and Scale CGContext - iOS

╄→尐↘猪︶ㄣ 提交于 2019-12-24 07:06:44
问题 Following from my previous question about Crop and Scale CMSampleBufferRef, I found a way to modify the CGContext inside that CMSampleBufferRef and I am able to draw rectangle, path, circle and clear rect of the CGContext, using the following code: - (void)modifyImage:(CMSampleBufferRef) sampleBuffer { CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); // Lock the image buffer CVPixelBufferLockBaseAddress(imageBuffer,0); // Get information about the image uint8_t

How to access CGContext for creating CGLayer offscreen

不想你离开。 提交于 2019-12-23 16:26:16
问题 Intention: creating CGLayer offscreen, draw some complicated stuff on it from second thread and use it later for quick drawing on main thread Problem: CGLayerCreateWithContext(context, size, info) expects an already existing CGContext so that it knows for what kind of context it needs to be optimized. Solution I found so far: CGContextRef ctx = UIGraphicSetCurrentContext() but this function doesn't seem to exist anymore. Question: Isn't there another way to access something like a default

How to draw a line between two points over an image in swift 3?

吃可爱长大的小学妹 提交于 2019-12-23 15:12:17
问题 I am new to swift, I want to draw a line between 2 points over an image which I called mapView, I tried to use CGContext but got no result, any idea to help? Thanks. UIGraphicsBeginImageContext(mapView.bounds.size) let context : CGContext = UIGraphicsGetCurrentContext()! context.addLines(between: [CGPoint(x:oldX,y:oldY), CGPoint(x:newX, y:newY)]) context.setStrokeColorSpace(CGColorSpaceCreateDeviceRGB()) context.setStrokeColor(UIColor.blue.cgColor.components!) context.setLineWidth(3) mapView?

CGContext & CGBitmapContextCreateImage errors, how to fix?

孤街浪徒 提交于 2019-12-23 12:13:53
问题 I've been at this for hours now, and don't even know how to debug this error. Maybe there's an SO expert who knows what's going on. - (void) prepareSubset { CGSize size = [image size]; float scale = fminf(1.0f, fmaxf(SUBSET_SIZE / cropRect.size.width, SUBSET_SIZE / cropRect.size.height)); CGPoint offset = CGPointMake(-cropRect.origin.x, -cropRect.origin.y); subsetWidth = cropRect.size.width * scale; subsetHeight = cropRect.size.height * scale; subsetBytesPerRow = ((subsetWidth + 0xf) >> 4) <<

xCode CGContextSaveGState: invalid context 0x0 Error

荒凉一梦 提交于 2019-12-23 05:22:50
问题 I just updated xCode to 7.0. My code was working before but now am I getting: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. In my application I have an inbox that displays an image/video once the message cell is selected. Before the messages were displaying fine but upon updating they no longer show. Is this a valid error or an Apple bug? The involved code is placed below. InboxTableViewController.m -

Merging two images of different size with rotate and zoom

自古美人都是妖i 提交于 2019-12-23 03:27:28
问题 I'm facing the following problem : I have to merge two images bottomImg and topImg to create a new image C as a result of the merging. I already know how to merge two images but in this case my goal is a little bit different. top image may be zoomed and rotated. I have follow this answer. But in this solution top image is cut while i rotate. simulator actual stored image is document like I have try this code _parentViewGIf for bottomImg and for _ivGIF for topImg - (UIImage *)mergeImage:

kCGTextStroke's Fill and Stroke aren't positioned correctly

被刻印的时光 ゝ 提交于 2019-12-22 11:37:34
问题 So I'm using the code below to apply a stroke (and fill) to text in a UILabel , and it's coming out like the image below. The stroke is heavier on one side than the other (look at the top of the letters compared to the bottom, and the right compared to the left. The period at the end makes it very noticeable, too, looks like a googly eye). I've not got any shadowing turned on at all, so I don't think it's the shadow interfering with the stroke. What could be causing this? - (void)