core-graphics

Static background for CGContext

梦想与她 提交于 2019-12-07 11:28:35
问题 this is my first question here, so hello everyone. I have spent some time now wrapping my mind around the following problem and could not come up with a solution. I'd be happy if someone could point me in the right direction. I'm using CGContext to draw various layers of graphical representations of live data which should be refreshed at a reasonable framerate of at least 50fps. I want to use a static image as a background. Re-drawing this image using the context for every cycle significantly

Event taps: Varying results with CGEventPost, kCGSessionEventTap, kCGAnnotatedSessionEventTap, CGEventTapPostEvent

安稳与你 提交于 2019-12-07 10:47:06
问题 I'm running into a thorny problem with posting an event from an event tap. I'm tapping for NSSystemDefined at kCGHIDEventTap, then replacing the event with a new one. The problem I'm running in to is that depending on how I post the event, it's being seen only by some applications. My test applications are Opera, Firefox, Quicksilver, and Xcode. Here are the different techniques I've tried within my event tap callback, with results. I'm expecting an action (the "correct response") from each

Sibling NSView z-ordering in Cocoa

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 10:21:34
问题 How does z-ordering work with sibling NSViews in Cocoa? I'm confused because I'm finding conflicting sources of information in Apple's docs and APIs. (Note: Subviews are obviously rendered on top of its parent view, I am talking explicitly about sibling views here). Hypothesis A : "Yes, you can define the z-order of sibling NSViews " In IB you can place views on top of each other and they will always be composited in the way you'd expect. There's buttons in Xcode under the Editor menu named

How to get author of image in cocoa

懵懂的女人 提交于 2019-12-07 08:47:29
问题 I can not understand why metaDic is always null. There is a code. CFDataRef dataRef = CGDataProviderCopyData(CGImageGetDataProvider(img.CGImage)); //(UIImage *img) CGImageSourceRef mySourceRef = CGImageSourceCreateWithData(dataRef, NULL); NSDictionary *metaDic = (NSDictionary *) CGImageSourceCopyPropertiesAtIndex(mySourceRef,0,NULL); NSDictionary *tiffDic = (NSDictionary *)[metaDic objectForKey:(NSString *)kCGImagePropertyTIFFDictionary]; NSString *AuthorName = [tiffDic objectForKey:(NSString

How to create embossed or shadow effects using Core Graphics (for finger paint)

北战南征 提交于 2019-12-07 05:09:41
问题 I have issue to implement "Emboss/Shadow effects" in my drawing. Finger paint functionality is currently working fine with my custom UIView and below is my drawRect method code: Edit code with all methods : - (void)drawRect:(CGRect)rect { CGPoint mid1 = midPoint(previousPoint1, previousPoint2); CGPoint mid2 = midPoint(currentPoint, previousPoint1); CGContextRef context = UIGraphicsGetCurrentContext(); [self.layer renderInContext:context]; CGContextMoveToPoint(context, mid1.x, mid1.y);

CGAffineTransformMakeRotation around external point

陌路散爱 提交于 2019-12-07 04:23:06
问题 are there a way for rotate UIImage around external point using CGAffineTranformMAkeRotation? tnx a lot! 回答1: Here is a function that uses the same format as the CoreGraphics CGAffineTransform API format. This works exactly how other "RotateAt()" APIs should work. The operation represents the equivalent of the following specification: translate(pt.x, pt.y); rotate(angle); translate(-pt.x, -pt.y); CGAffineTransform CGAffineTransformMakeRotationAt(CGFloat angle, CGPoint pt){ const CGFloat fx =

iOS - CoreImage - Add an effect to partial of image

核能气质少年 提交于 2019-12-07 04:11:58
问题 I just have a look on CoreImage framework on iOS 5, found that it's easy to add an effect to whole image. I wonder if possible to add an effect on special part of image (a rectangle). for example add gray scale effect on partial of image/ I look forward to your help. Thanks, Huy 回答1: Watch session 510 from the WWDC 2012 videos. They present a technique how to apply a mask to a CIImage . You need to learn how to chain the filters together. In particular take a look at: CICrop ,

How to Searching String from PDF using iphone sdk?

大憨熊 提交于 2019-12-07 00:44:14
问题 I am trying to create a PDF Reader application allow user to search string from the PDF. The very simple idea for displaying the PDF in webView but I don't know whether I can perform search in the PDF displayed in UIWebView or not? If this is possible then please provide me any good tutorial for this. If not then I am using CGPDFDocumentRef and other classes of CoreGraphics. I am done with displaying PDF on a UIView without having UIWebView. I am unable to Zoom yet but it is displaying. Now

iPhone Core Graphics thicker dashed line for subview

空扰寡人 提交于 2019-12-06 23:17:31
问题 I have a UIView and within it I've drawn a line using Core Graphics by overriding drawRect . This view also contains one subview which also draws a line. However, whilst both views are using pretty much the same code (for testing purposes at least), the lines drawn on them do not appear the same: As you can see - the dashed line at the top is noticeably thicker than the bottom one and I have no idea why. Below is the code used by the two UIViews in their drawRect methods. If you have any idea

How to get a CGImageRef from Context-Drawn Images?

那年仲夏 提交于 2019-12-06 21:41:01
问题 Ok using coregraphics, I'm building up an image which will later be used in a CGContextClipToMask operation. It looks something like the following: UIImage *eyes = [UIImage imageNamed:@"eyes"]; UIImage *mouth = [UIImage imageNamed:@"mouth"]; UIGraphicsBeginImageContext(CGSizeMake(150, 150)); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetRGBFillColor(context, 0, 0, 0, 1); CGContextFillRect(context, bounds); [eyes drawInRect:bounds blendMode:kCGBlendModeMultiply alpha:1];