core-graphics

How do I draw a simple ellipse using CoreGraphics on the iPhone (specifically iPad)?

不想你离开。 提交于 2020-01-03 19:34:10
问题 Just wondering how to draw an ellipse using CoreGraphics. 回答1: CGContextStrokeEllipseInRect or CGContextFillEllipseInRect 来源: https://stackoverflow.com/questions/3231902/how-do-i-draw-a-simple-ellipse-using-coregraphics-on-the-iphone-specifically-ip

Higlight Artifacts When Using Hard Light Blend Mode

不羁岁月 提交于 2020-01-03 18:02:34
问题 I'm blending two images in my iPhone app, using the HardLight blend mode of the top image. It looks something like this: UIGraphicsBeginImageContext(size); [sourceImage drawInRect:rectangle blendMode:kCGBlendModeNormal alpha:1.0]; [effectOverlay drawInRect:rectangle blendMode:kCGBlendModeHardLight alpha:0.75]; mainImage.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); It works fine. However, the blown-out highlights in the image appear with a weird color

Which parts of UIKit, Core Graphics, Core Animation, OpenGL are allowed on non main-thread?

爷,独闯天下 提交于 2020-01-03 09:28:10
问题 In my OpenGL-ES 1.1 based app, I'm using CALayer s as a source for OpenGL textures. Those CALayer s comprise of CGImage s and text rendered through CoreGraphics. Another OpenGL texture source is a screenshot of a UIView taken using -[CALAyer renderInContext:] and UIGraphicsGetImageFromCurrentImageContext . Currently, I'm running completely on the main thread. The latter case in particular is pretty bad because it halts the OpenGL rendering for the whole time it takes to create the UIView and

A string with '-' character is not drawing properly in drawrect method in iOS

两盒软妹~` 提交于 2020-01-03 06:04:56
问题 I'm working on coretext in iOS. I have implemented a custom UIView by replacing -drawRect method with the following code: - (void)drawRect:(CGRect)rect { [super drawRect:rect]; CGRect frameRect=CGRectMake(50, 200, 80, 15); // NSString *textToDraw=@"A-BCDEFGHIJKLM"; // NSString *textToDraw=@"abc"; // NSString *textToDraw=@"ABCDEFGHIJKLMNOPQRST"; NSString *textToDraw=@"A-BCDEFGHIJ"; // NSString *textToDraw=@"A-BCDEFGHI"; CFStringRef stringRef = (__bridge CFStringRef)textToDraw;

Draw centered text using core graphics (mobile device)

好久不见. 提交于 2020-01-03 05:14:09
问题 I'm using this code: CGRect screenRect = [[UIScreen mainScreen] bounds]; CGFloat screenWidth = screenRect.size.width; CGFloat screenHeight = screenRect.size.height; NSString * text = @"text"; CGContextSetFillColorWithColor(context, [UIColor colorWithRed:1 green:1 blue:1 alpha:RETICLE_ALPHA].CGColor); [text drawAtPoint:CGPointMake(screenWidth/2, screenHeight/2) withFont: [UIFont systemFontOfSize:22.0]]; to create a centered "text" for iOS. But I'm not sure how to edit the code above to really

Does CGContextSetTextMatrix work for offscreen bitmaps?

感情迁移 提交于 2020-01-02 09:44:46
问题 I'm creating an image offscreen using a context from CGBitmapContextCreate() . While drawing text, I tried to use the: CGContextSetTextMatrix(contextRef, CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, 0.0)); but my text was still upside down. If I used the standard transforms it was correct: CGContextTranslateCTM(contextRef, 0.0, contextRect.size.height); CGContextScaleCTM(contextRef, 1.0, -1.0); My question is should the CGContextSetTextMatrix work for an offscreen bitmap? Maybe I was doing

Does CGContextSetTextMatrix work for offscreen bitmaps?

人盡茶涼 提交于 2020-01-02 09:42:13
问题 I'm creating an image offscreen using a context from CGBitmapContextCreate() . While drawing text, I tried to use the: CGContextSetTextMatrix(contextRef, CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, 0.0)); but my text was still upside down. If I used the standard transforms it was correct: CGContextTranslateCTM(contextRef, 0.0, contextRect.size.height); CGContextScaleCTM(contextRef, 1.0, -1.0); My question is should the CGContextSetTextMatrix work for an offscreen bitmap? Maybe I was doing

Does CGDataProviderCopyData() actually copy the bytes? Or just the pointer?

删除回忆录丶 提交于 2020-01-02 09:04:46
问题 I'm running that method in quick succession as fast as I can, and the faster the better, so obviously if CGDataProviderCopyData() is actually copying the data byte-for-byte, then I think there must be a faster way to directly access that data...it's just bytes in memory. Anyone know for sure if CGDataProviderCopyData() actually copies the data? Or does it just create a new pointer to the existing data? 回答1: The bytes are copied. Internally a CFData is created (CFDataCreate) with the content

How to get window list from core-grapics API with swift

心已入冬 提交于 2020-01-02 06:47:07
问题 I´m trying to get a list of windows on OSX from the core-graphics API with Swift (to capture an image of them later on). After some research I found the CGWindowListCopyWindowInfo Objective-C API call with the following signature: CFArrayRef CGWindowListCopyWindowInfo( CGWindowListOption option, CGWindowID relativeToWindow ); Parameters option: The options describing which window dictionaries to return. Typical options let you return dictionaries for all windows or for windows above or below

Gradient ALONG a CGPath

人走茶凉 提交于 2020-01-02 06:27:21
问题 I am drawing an arc that is an almost complete circle: CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor); CGMutablePathRef path = CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, centerPoint.x, centerPoint.y); CGPathAddArc(path, NULL, centerPoint.x, centerPoint.y, radius, (float)(3.0f * M_PI_2), radians, !clockwise); CGPathCloseSubpath(path); CGContextAddPath(context, path); CGContextFillPath(context); CGPathRelease(path); I have an arc like path that is an almost