quartz-2d

CGContext line drawing: CGContextFillPath not working?

牧云@^-^@ 提交于 2019-11-30 11:46:06
Anyone have any idea why CGContextFillPath won't work in the code snippet below? I'm using the following code to draw to a UIImageView. It's stroking the path correctly, but ignoring CGContextFillPath. UIGraphicsBeginImageContext(self.frame.size); [drawingView.image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0); CGContextSetAllowsAntialiasing(UIGraphicsGetCurrentContext(), YES); CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1

How to implement alpha gradient on a image?

故事扮演 提交于 2019-11-30 06:25:13
问题 I want to implement alpha gradient on an image. From 0.5 alfa on top of the image to 0.0 on bottom. Any advice, tutorial, link is welcome. 回答1: You can use CGImageCreateWithMask to apply a masking image to it. You could generate an appropriate mask simply enough by drawing to a greyscale or alpha-only CGBitmapContext with CGContextDrawLinearGradient . If it's being displayed as the content of a CALayer, you could apply an appropriate masking layer to the parent layer's mask property. You

How to set a gradient border on UIView?

烂漫一生 提交于 2019-11-30 05:25:06
It's very easy to put a simple border on a UIView . You simply link to QuartzCore , import it, and use: self.view.layer.borderColor = [UIColor redColor].CGColor; self.view.layer.borderWidth = 2.0f; My question is... Is there a way to make this border use a gradient. I know how to apply a gradient mask to the entire view, but not just to its border. I'm assuming this could involve a custom view and CoreGraphics drawing inside drawRect: , but I'm not sure where to start. I'm not entirely sure of what you mean by "gradient". Since you've said you've used core graphics to apply a gradient to a

Drawing a circle ,filled different parts with different color

不羁岁月 提交于 2019-11-30 04:26:07
I am a novice ios programmer.In one of my project i need to draw a circle in which different portion of the circle would be filled up with different colors.I can draw the circle.But i am not being able to determine the different portion of the circle and fill them with different color.Here is an screenshot to clarify what i want to draw. A help would be appreciated. You can use UIBezierPath which has a method addArcWithCenter:radius:startAngle:endAngle:clockwise: where you can specify radius, center and angles. The code could look like this which draws a quarter of a circle in green: CGPoint

How to use a UIImage as a mask over a color in Objective-C

有些话、适合烂在心里 提交于 2019-11-30 01:50:34
I have a UIImage that is all black with an alpha channel so some parts are grayish and some parts are completely see-through. I want to use that images as a mask over some other color (let's say white to make it easy), so the final product is now a white image with parts of it transparent. I've been looking around on the Apple documentation site here: http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_images/dq_images.html#//apple_ref/doc/uid/TP30001066-CH212-CJBHIJEB But I'm completely new to Quartz/Core Graphics, so I don't can't really

Perspective correction of UIImage from Points

孤街醉人 提交于 2019-11-29 22:41:29
I'm working on a app where I'll let the user take a picture e.g of a business card or photograph. The user will then mark the four corners of the object (which they took a picture off) - Like it is seen in a lot of document/image/business card scanning apps: My question is how do i crop and fix the perspective according to these four points? I've been searching for days and looked at several image proccessing libraries without any luck. Any one who can point me in the right direction? From iOS8+ there is Filter for Core Image called CIPerspectiveCorrection . All you need to do is pass the

iPhone, CGPDFDocument - PDF links

半城伤御伤魂 提交于 2019-11-29 20:42:49
I'm trying to write a simple PDF viewer using CGPDFDocument , based on QuartzDemo. There is common rendering: -(void)drawInContext:(CGContextRef)context { // PDF page drawing expects a Lower-Left coordinate system, // so we flip the coordinate system before we start drawing. CGContextTranslateCTM(context, 0.0, self.bounds.size.height); CGContextScaleCTM(context, 1.0, -1.0); // Grab the first PDF page CGPDFPageRef page = CGPDFDocumentGetPage(pdf, pageNumber); // We're about to modify the context CTM to draw the PDF page // where we want it, so save the graphics state // in case we want to do

Create UIImage from shadowed view while retaining alpha?

白昼怎懂夜的黑 提交于 2019-11-29 16:59:35
I have a somewhat unusual problem. In my app, I am shadowing a UIImageView using basic Quartz2d layer shadowing. Here's my code: imageView.layer.shadowOpacity = 1.0; // Pretty self explanatory imageView.layer.shadowRadius = 8.0; // My softness imageView.layer.shadowColor = [UIColor blackColor].CGColor; // Color of the shadow imageView.layer.shadowOffset = CGSizeMake(0.0, 0.0); // Offset of the shadow This produces a nice blur behind the image view. However, I am doing some animation with this view, and the constant recalculation of the shadowing during the transitions causes a very choppy

On iOS, after we create a layer from context and get the layer's context, how do these contexts relate to each other?

拟墨画扇 提交于 2019-11-29 15:48:17
We can create a layer from the current graphics context and then get the layer's context: CGContextRef context = UIGraphicsGetCurrentContext(); CGLayerRef layer = CGLayerCreateWithContext(context, CGSizeMake(self.frame.size.width, self.frame.size.height), NULL); CGContextRef contextOfLayer = CGLayerGetContext(layer); So we now have 2 contexts: context and contextOfLayer . How do these two contexts relate to each other? Is contextOfLayer actually part of context and context has a array of layer context pointers? If I print out their addresses using NSLog(@"%p", ...) , they have different

Drawing a circle ,filled different parts with different color

别等时光非礼了梦想. 提交于 2019-11-29 01:13:26
问题 I am a novice ios programmer.In one of my project i need to draw a circle in which different portion of the circle would be filled up with different colors.I can draw the circle.But i am not being able to determine the different portion of the circle and fill them with different color.Here is an screenshot to clarify what i want to draw. A help would be appreciated. 回答1: You can use UIBezierPath which has a method addArcWithCenter:radius:startAngle:endAngle:clockwise: where you can specify