core-graphics

How do I create a new image by drawing on top of an existing one using Quartz?

别等时光非礼了梦想. 提交于 2019-12-04 12:27:43
问题 i have a view with uiimageview i assign this uiimageview image by camera..now i want to do some drawing onto image....using coregraphics.i want to do something like this... select an area by touching and drawing line when line joins something like circle or any shape..i want to change that particular area in to something else for example change color there.turn that into grayscale.. till now i am able to draw line...here is an image of line drawn over a uiimage view... but i am unable to

How to adjust drop shadow dynamically during an UIImageView rotation?

我只是一个虾纸丫 提交于 2019-12-04 12:02:59
问题 I use the following to code to add drop shadow: letterE.layer.shadowColor = [[UIColor blackColor] CGColor]; letterE.layer.shadowOffset = CGSizeMake(2.5, 2.5); letterE.layer.shadowRadius = 3.0; letterE.layer.shadowOpacity = 0.95; and the following to rotate: CABasicAnimation* rotationAnimation; rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0]; rotationAnimation.duration = 5.0;

How to free memory in ARC for high memory usage graphics render?

泪湿孤枕 提交于 2019-12-04 11:25:23
First off, thank you to everyone on this site...it's been INCREDIBLY helpful in getting into the grit of iOS programming. My current issue: I have an app that renders a very stylized version of a photo. It uses some CoreImage filters for some of it, but needs a bunch of CoreGraphics to get the heavy image processing done. The proxy size renders work out great, but when I render a full resolution version of my image, it sometimes crashes because of high memory usage. The problem is that I need to be able to have several full resolution (3264x2448) buffers in memory when rendering. I don't know

Horizontal Flip of a frame in Objective-C

时间秒杀一切 提交于 2019-12-04 10:36:50
I am trying to create a filter for my program (which streams a webcam) which makes the frame flip horizontally, making the webcam act like a mirror. However, while it compiles and runs, the filter does not seem to have any effect on it. Here is the code: CIImage *resultImage = image; CIFilter *flipFilter = [CIFilter filterWithName:@"CIAffineTransform"]; [flipFilter setValue:resultImage forKey:@"inputTransform"]; NSAffineTransform* flipTransform = [NSAffineTransform transform]; [flipTransform scaleXBy:-1.0 yBy:1.0]; //horizontal flip [flipFilter setValue:flipTransform forKey:@"inputTransform"];

Gradient effect for Line Graph in iPhone

点点圈 提交于 2019-12-04 10:25:50
I'm trying to generate a graph with gradient/shading effect. Now I'm able to draw line graph and applied gradient effect to that graph. It is applying to whole view not to the graph. Now I'm getting image like this. But I want like this. I want gradient effect just under the graph. Please help me in this. Thanks in advance. The code that I'm using is: UIGraphicsBeginImageContext(self.graphView.frame.size); [graphView.image drawInRect:CGRectMake(0, 0, self.graphView.frame.size.width, self.graphView.frame.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);

Subtract CGRect from CGRect — largest piece of one not containing the other

折月煮酒 提交于 2019-12-04 10:15:18
问题 How I can substract one CGRect from another? I want the result R1 - R2 to be the largest subrectangle of R1 that does not intersect R2. Example 1 : +----------------------------------+ | +--------+ | | | R2 | | | | | | | +--------+ R1 | | | | | | | +----------------------------------+ R3 = CGRectSubstract(R2,R1); +----------------------+ | | | | | | | R3 | | | | | | | +----------------------+ Example 2 : +-----------------------+----------+ | | | | | R2 | | | | | R1 +----------+ | | | | | | +

How can I fill a rect with an alpha color using CoreGraphics?

落花浮王杯 提交于 2019-12-04 10:01:54
In my drawRect method, I am drawing a PNG image. On top of that, I want to draw a rect with a 20% alpha color, like this: [[UIColor colorWithWhite:0.0 alpha:0.2] set]; UIRectFill(rect); The problem is, that the alpha property seems to get ignored. No alpha is applied at all, just a black rectangle is drawn. How can I fix this? Thanks in advance! Use CGContextSetBlendMode() before you draw the rect. Set your view background color to transparent… It should work. 来源: https://stackoverflow.com/questions/2935608/how-can-i-fill-a-rect-with-an-alpha-color-using-coregraphics

Xcode: compositing with alpha using core image

丶灬走出姿态 提交于 2019-12-04 09:53:28
问题 I'd like to create a CoreImage filter chain, and to be able to control the "intensity" of each filter in the chain by compositing its individual effect with alpha, or opacity settings, but I am not seeing a way to composite with alpha or opacity in the docs. I could jump out of Core image filter chain and composite with a core graphics context I guess. 回答1: The CIColorMatrix filter can be used to alter the alpha component of a CIImage, which you can then composite onto a background image:

Why is -drawRect faster than using CALayers/UIViews for UITableViews?

丶灬走出姿态 提交于 2019-12-04 09:43:25
问题 I can already hear the wrenching guts of a thousand iOS developers. No, I am not noob. Why is -drawRect faster for UITableView performance than having multiple views? I understand that compositing operations take place on the GPU. But compositing is a one-time operation; once the layers are committed to memory, it is no different from a cached buffer that, from the point of view of the GPU, gets translated in and out of view. Compare this to using Core Graphics in drawRect, which employ an

How to draw a concentric circle in iphone?

只谈情不闲聊 提交于 2019-12-04 09:31:14
问题 I want to draw a ring. Ring should filled in a outer circle. I referred a documentation http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_paths/dq_paths.html#//apple_ref/doc/uid/TP30001066-CH211-TPXREF101. But still had problem to get the outcome. Here is the code. CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextClearRect(ctx, rect); CGContextSetRGBFillColor(ctx, 0.0, 255.0, 1.0, 1.0);CGContextFillPath(ctx);