quartz-graphics

How can I highlight a chunk of text on an image taken by Camera view

北城以北 提交于 2019-12-21 21:55:16
问题 I am working on an OCR project. My first task is to take an image from iPhone camera and then locate a specific word on the image. Below is a sample image taken by my device, now I want to find the position of word "STATIONERY" and highlight it with a yellow rectangle on image. How can I do that? Do I need to first use an OCR SDK for that (like ABBYY) or can I do this otherwise? 回答1: If you need to get the coordinates of a specific word, of course you need to perform OCR first. Keep in mind

Quartz 2d / Core Graphics: What is the right way to draw some text?

笑着哭i 提交于 2019-12-21 12:24:25
问题 I've been at this for awhile, it seems that there's many ways to go about this in quartz 2d: 1) Draw text using core graphics methods... CGContextSelectFont CGContextSetRGBFillColor CGContextShowTextAtPoint and on and on, which is horribly low level. 2) using NSString drawAtPoint (so far the method I like) NSString* text = @"Hello"; [text drawAtPoint:point withFont:font]; 3) using UILabel I've read this somewhere but not too sure if this is possible. but I'm thinking that instantiating a

CALayer delegate method drawLayer not getting called

旧城冷巷雨未停 提交于 2019-12-21 07:23:10
问题 My object a sub class of NSObject has CALayer instance variable. I use it for drawing and caching content with its delegate set to my object. But for some reason drawLayer:inContext: method NEVER gets called. Whereas actionForLayer:forKey: delegate method does get called implying the delegate is getting set properly with layer.delegate = self in the object's init method. Any suggestions on what is preventing my layer drawing method drawLayer:inContext: from getting called ? I am called the

How can I save a Bitmap Image, represented by a CGContextRef, to the iPhone's hard drive?

ぃ、小莉子 提交于 2019-12-21 06:27:00
问题 I have a little sketch program that I've managed to throw together using Quartz2D, but I'm very new to the iOS platform and I'm having trouble figuring out how to allow the user to save their sketch. I have a CGContextRef that contains the sketch, how can I save it so that it can later be retrieved? Once it's saved, how can I retrieve it? Thanks so much in advance for your help! I'm going to continue reading up on this now... 回答1: There are different types of CGContexts. You are most likely

How to draw signature with lines on iPhone screen?

旧街凉风 提交于 2019-12-21 06:02:08
问题 I want to let user draw a signature on iPhone screen, so I add a subclass of UIView and add some code to its 'touchesMoved' method. -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; firstTouch = [touch locationInView:self]; CGSize mySize = CGSizeMake(5, 5); UIGraphicsBeginImageContext(mySize); CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextBeginPath(ctx); CGContextSetRGBFillColor(ctx, 1, 0, 0, 1); CGContextAddRect(ctx,

Can you set the anchorPoint of the root layer on an NSView?

风格不统一 提交于 2019-12-21 05:43:04
问题 Is it possible to modify the anchorPoint property on the root CALayer of a layer-backed NSView ? I have a view called myView and it seems every time I set the anchorPoint , it gets overridden in the next run loop. I am doing this: NSView *myView = [[myView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)]; //set the root layer myView.layer = [CALayer layer]; myView.wantsLayer = YES; //gets overridden on the next run loop myView.layer.anchorPoint = CGPointMake(1,1); 回答1: On 10.8, AppKit will

How to draw text inner shadow on Cocoa for Mac OS X

本小妞迷上赌 提交于 2019-12-21 05:23:07
问题 How do I draw an inner shadow on a text in Cocoa for Mac OS X? I am subclassing NSView to create a placeholder control with a gradient background and an inner shadowed text title over it. All current Core Graphics answers on stackoverflow seem to explain drawing text shadows on Cocoa Touch. 回答1: You might think too complicated. If I get your problem right, the only thing you actually want to do is to set the text style. Then do so by simply using: [[object cell] setBackgroundStyle

how to create a strong red glow effect on UILabel

耗尽温柔 提交于 2019-12-21 05:03:05
问题 I need to implement outer glow effect on UILabel (or CATextLayer) as above. I know to create glow effect on text, I need shadow with offset (0,0). I've touched down to the quartz2D level, following is the code I'm using: _backgroundDownLabel.layer.shadowColor = self.glowColor.CGColor; // red _backgroundDownLabel.layer.shadowOffset = CGSizeMake(0, 0); _backgroundDownLabel.layer.shadowOpacity = 1; _backgroundDownLabel.layer.shadowRadius = self.glowAmount; // tried 1-10 _backgroundDownLabel

CGContextClipToMask returning blank image

佐手、 提交于 2019-12-21 04:12:08
问题 I'm new to Quartz. I have 2 images, a background, and a mask with cutout shape that I want to lay over the background in order to cut out a section. The resulting image should be the shape of the cutout. This is my mask (the shape in the middle is 0 alpha): And this is my code: UIView *canvas = [[[sender superview] subviews] objectAtIndex:0]; UIGraphicsBeginImageContext(canvas.bounds.size); CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef cgContext =

iOS Drawing Circles

落花浮王杯 提交于 2019-12-21 01:09:48
问题 I am trying to create the circles below in my iOS app. I know how to make the circles but am not entirely sure on how to get the points along the arc. It has to be in code not an image. Below is also the code I currently have. - (void)drawRect:(CGRect)rect { CGPoint point; point.x = self.bounds.origin.x + self.bounds.size.width/2; point.y = self.bounds.origin.y + self.bounds.size.height/2; CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 2.0);