cglayer

Computing a UIImage to be saved to the photo album

风流意气都作罢 提交于 2020-01-06 02:39:04
问题 I basically want to automatically create a tiled image from a bunch of source images, and then save that to the user's photo album. I'm not having any success drawing a bunch of small UIImage's into one big UIImage. What's the best way to accomplish this? Currently I'm using UIGraphicsBeginImageContext() and [UIImage drawAtPoint], etc. All I ever end up with is a 512x512 black square. How should I be doing this? I'm looking to CGLayer's, etc. seems there are a lot of options but none that

How to access CGContext for creating CGLayer offscreen

不想你离开。 提交于 2019-12-23 16:26:16
问题 Intention: creating CGLayer offscreen, draw some complicated stuff on it from second thread and use it later for quick drawing on main thread Problem: CGLayerCreateWithContext(context, size, info) expects an already existing CGContext so that it knows for what kind of context it needs to be optimized. Solution I found so far: CGContextRef ctx = UIGraphicSetCurrentContext() but this function doesn't seem to exist anymore. Question: Isn't there another way to access something like a default

Why does my view jump when setting the layer anchorPoint in an animation block?

半城伤御伤魂 提交于 2019-12-22 17:39:08
问题 I have a UIPanGestureRecognizer attached to a view in my iOS app. I copied the code from the Touches sample app for the pan handler. When the gesture starts, my code: Records the original anchor point and center. Changes the anchor point and center to be around the user's fingers, like so: CGPoint locationInView = [gestureRecognizer locationInView:target]; CGPoint locationInSuperview = [gestureRecognizer locationInView:target.superview]; target.layer.anchorPoint = CGPointMake( locationInView

How to use CgLayer for optimal drawing

前提是你 提交于 2019-12-20 07:25:59
问题 I have created a simple drawing project,the code works fine, but I want to cache the drawing into CGlayer, because I read that its more efficient way in drawing . I have read through the documents, but not able to understand it properly. So friends, I request you to please help me in this regard. Below is my code, I want to know how to use CgLayer in this - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); if(myLayerRef == nil) { myLayerRef =

CGLayerRef in NSValue - when to call retain() or release()?

戏子无情 提交于 2019-12-20 05:42:20
问题 I am caching some graphics onto CGLayers and then storing them in NSValue objects using @encode (so as to store them in an array). I just wanted to make sure that I handle the retain/release correctly... I cache the graphics and store them in the array something like this: // Create an NSMutableArray "newCache" CGLayerRef drawingLayer = CGLayerCreateWithContext(context, bounds.size, NULL); CGContextRef drawingContext = CGLayerGetContext(drawingLayer); // Do some drawing... [newCache addObject

What's the difference and compatibility of CGLayer and CALayer?

放肆的年华 提交于 2019-12-17 17:26:00
问题 I'm confusing CGLayer and CALayer . They look similar, so why are there separate implementations? What's the difference between, and compatibility of, CGLayer and CALayer ? 回答1: They are completely different, and not compatible. To be absolutely clear: it is strictly a coincidence that the word "layer" is used in both names ; they are completely unrelated . CGLayers are a "special" "high performance" thingy. You could consider them "like bitmaps, but better." Apple sat down and said "We're

Drawing getting pixelated in iOS

无人久伴 提交于 2019-12-13 05:08:53
问题 I am working on a drawing application, I am drawing into CGlayers , I am creating a CGlayer this way -(void)drawRect { if(self.DrawingLayer == nil) { CGFloat scale = self.contentScaleFactor; CGRect bounds = CGRectMake(0, 0, self.bounds.size.width * scale, self.bounds.size.height * scale); CGLayerRef layer = CGLayerCreateWithContext(context, bounds.size, NULL); CGContextRef layerContext = CGLayerGetContext(layer); CGContextScaleCTM(layerContext, scale, scale); self.DrawingLayer = layer; }

Create CGContext for CGLayer

99封情书 提交于 2019-12-13 03:36:32
问题 I want to pre-render some graphics into CGLayer for fast drawing in future. I found that CGLayerCreateWithContext requires a CGContext parameter. It can be easily found in drawRect: method. But I need to create a CGLayer outside of drawRect: . Where should I get CGContext ? Should I simply create temporary CGBitmapContext and use it? UPDATE: I need to create CGLayer outside of drawRect: because I want to initialize CGLayer before it is rendered. It is possible to init once on first drawRect

Draw one CGlayer into another CGlayer

房东的猫 提交于 2019-12-11 08:23:33
问题 I am using two CGlayers for drawing, Layer1 and Layer2, I draw into Layer1 and on touches end, I transfer the data into Layer2 and just clear Layer1, and in my drawRect, method, I draw both layers to context. On erase button clicked, I transfer the drawing from Layer2 to Layer1 and then I erase layer1, but on touches end, I dont transfer it to Layer2, because I only erase Layer1 On pen clicked If erase has happened, I transfer drawing from Layer1 to Layer2, otherwise previous drawing can

Memory issues with CGlayer

怎甘沉沦 提交于 2019-12-11 05:29:09
问题 I am working CGlayers for drawing. I have implemented the drawing part, the drawingView(canvas) where the user will draw is dynamic, what I mean by this is, user can increase/decrease height of the drawingView(Canvas) For example by default size - 500*200 When user clicks on expand button - 500*300 So here is my function when user expands the canvas, - (void)IncreaseCanavasSize { CGContextRef layerContext1 = CGLayerGetContext(permanentDrawingLayer ); CGContextDrawLayerInRect(layerContext1,