core-graphics

Using circular progress bar with masked image?

时光毁灭记忆、已成空白 提交于 2019-12-21 01:40:07
问题 I am working on a circular progress bar for custom game center achievements view and I have kind of "hit the wall". I am struggling with this for over two hours and still cannot get it to work. The thing is, that I need a circular progress bar, where I would be able to set (at least) the track(fill) image. Because my progress fill is a rainbow like gradient and I am not able to achieve the same results using only code. I was messing with CALayers, and drawRect method, however I wasn't

CoreGraphics drawing causes memory warnings/crash on iOS 7

徘徊边缘 提交于 2019-12-20 19:43:55
问题 After updating my iPad (mini) to iOS7 I experienced that my drawing app is lagging and crashing after a few strokes. Now, when I run the app with Instruments/memory allocation tool in xcode 5, I see that the VM: CG raster data category is filling up rapidly when drawing on the screen. There seems to be a multitude of CGDataProviderCreateWithCopyOfData calls being made, each 3.00Mb in size. After continous drawing the app receives memory warnings, and usually terminates. The code basically

CoreGraphics FillPath And Stroke Path

不问归期 提交于 2019-12-20 17:29:44
问题 I need to draw an hexagon and fill it with a color build with an Image as pattern. I did: CGContextSaveGState(context); CGContextSetLineCap(context, kCGLineCapRound); CGContextSetFillColorWithColor(context, [[UIColor colorWithPatternImage:[UIImage imageNamed:@"patternerba.png"]] CGColor]); CGContextSetStrokeColorWithColor(context, [[UIColor blackColor] CGColor]); CGContextSetLineWidth(context, 3.0); // drawing hexagon here... CGContextStrokePath(context); CGContextFillPath(context); [

CoreGraphics FillPath And Stroke Path

泄露秘密 提交于 2019-12-20 17:29:01
问题 I need to draw an hexagon and fill it with a color build with an Image as pattern. I did: CGContextSaveGState(context); CGContextSetLineCap(context, kCGLineCapRound); CGContextSetFillColorWithColor(context, [[UIColor colorWithPatternImage:[UIImage imageNamed:@"patternerba.png"]] CGColor]); CGContextSetStrokeColorWithColor(context, [[UIColor blackColor] CGColor]); CGContextSetLineWidth(context, 3.0); // drawing hexagon here... CGContextStrokePath(context); CGContextFillPath(context); [

Loading UIImage in background thread causes ImageIO error

ぐ巨炮叔叔 提交于 2019-12-20 15:33:34
问题 I am working on an iOS project that loads UIImages from URLs in a background thread and displays them in a horizontally paged scroll view. This behavior should mimic that of the native photo library application for iPhone. I have everything setup in a way that I believe should work, but upon drawing the UIImages in the main UI graphics context, I occasionally see this message print out in the console: ImageIO: <ERROR> CGImageReadSessionGetCachedImageBlockData ***

When drawing an arc using CGContextAddArcToPoint(), what does (x1,y1) and (x2,y2) mean?

▼魔方 西西 提交于 2019-12-20 12:28:20
问题 You can use the following code to draw an arc using Quartz: CGContextMoveToPoint(context2, x, y); CGContextAddArcToPoint(context2, x1, y1, x2, y2, r); In these functions, (x,y) is the starting point and r is the arc radius but what are (x1,y1) and (x2,y2) ? 回答1: http://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CGContext/Reference/reference.html#//apple_ref/c/func/CGContextAddArcToPoint x1 : The x-value, in user space coordinates, for the end point of the first

How do I use CGAffineTransformMakeScale and Rotation at once?

烈酒焚心 提交于 2019-12-20 12:07:11
问题 ((UIImageView*)[dsry objectAtIndex:0]).transform = CGAffineTransformMakeRotation(1.57*2); ((UIImageView*)[dsry objectAtIndex:0]).transform = CGAffineTransformMakeScale(.5,.5); Just one of these works at a time. How can I save a transformation and then apply another? Cheers 回答1: To expand upon what Peter said, you would want to use code like the following: CGAffineTransform newTransform; newTransform = CGAffineTransformMakeRotation(1.57*2); ((UIImageView*)[dsry objectAtIndex:0]).transform =

Just in theory: How is the alpha component premultiplied into the other components of an PNG in iPhone OS, and how can it be unpremultiplied properly?

荒凉一梦 提交于 2019-12-20 10:57:36
问题 Actually, I thought that there would be an easy way to achieve that. What I need is pure alpha value information. For testing, I have a 50 x 55 px PNG, where on every edge a 5x5 pixel rectangle is fully transparent. In these areas alpha has to be 0.Everywhere else it has to be 255. I made very sure that my PNG is created correctly, and it also looks correctly. Please tell me if this is theoretically correct: I created an CGImageRef that has only the alpha channel and nothing else. This is

iOS Colors Incorrect When Saving Animated Gif

家住魔仙堡 提交于 2019-12-20 10:39:42
问题 I am having this very strange issue. I am creating animated gifs from UIImages and most of the time they come out correct. However when I start to get into larger size images my colors start to disappear. For example if I do a 4 frame 32 x 32 pixel image with no more than 10 colors no issue. If I scale the same image up to 832 x 832 I lose a pink color and my brown turns green. @1x 32 x 32 @10x 320 x 320 @26x 832 x 832 Here is the code I use to create the gif... var kFrameCount = 0 for

Why does drawRect: work without calling [super drawrect:rect]?

这一生的挚爱 提交于 2019-12-20 10:38:14
问题 I'm overriding drawRect: in one of my views and it works even without calling [super drawrect:rect]. How does that work? - (void)drawRect:(CGRect)rect{ CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetBlendMode(context, kCGBlendModeDestinationOver); [[UIColor clearColor] setFill]; UIRectFill(CGRectMake(0,0,100,100)); } 回答1: From the documentation: "The default implementation of this method does nothing.Subclasses that use technologies such as Core Graphics and UIKit to draw