core-graphics

Using iPhone/Objective C CGFloats: Is 0.1 okay, or should it be 0.1f?

[亡魂溺海] 提交于 2019-12-02 06:28:41
When using an iPhone Objective C method that accepts CGFloat s, e.g. [UIColor colorWithRed:green:blue:] , is it important to append a f to constant arguments to specifiy them explicitly as floats, e.g. should I always type 0.1f rather than 0.1 in such cases? Or does the compiler automatically cast 0.1 (which is a double in general) to 0.1f (which is a float) at compile time? I don't wish to have these casts happen at run time because they would unneccessarily hog performance. Thanks in advance MrMage It's not important ; it won't break anything to use a double-precision constant where a single

Keep text on an image readable while rotating the image

≯℡__Kan透↙ 提交于 2019-12-02 05:55:27
问题 I have an image view that looks like a wheel. This view detects touch events on each of the colored sections. The problem I have is that when I rotate this wheel, the UILabel s on top of the view need to also be rotated so that the text is still horizontal and human readable. What is the best way to rotate the labels while the parent view is being rotated? This is what I am trying now and it does not rotate correctly... CGAffineTransform textTransform = CGAffineTransformRotate(newTransform,

Draw a path with variable width in iOS

十年热恋 提交于 2019-12-02 05:42:07
I am working on a writing application, My writing is working fine, but what I want to implement is variable stroke width , so that the writing is very realistic and intuitive, as done by " BAMBOO " and " PENULTIMATE " application. Firstly I want to tell you what I have tried. 1) In iOS, their is no pressure detection, or velocity detection according to my research. For velocity detection, I have to use OPENGL. 2) Due to these limitations, I tried using the method given in this tutorial which is pretty straight forward.Here is the link http://mobile.tutsplus.com/tutorials/iphone/ios-sdk

UIColor SetFill doesn't work

ε祈祈猫儿з 提交于 2019-12-02 04:50:42
In this code for (int i=0;i<3;i++) { CGContextAddLineToPoint(context, self.xShift+15+self.rectLen*self.width+self.rectLen*(i+1), self.yShift+self.rectLen*10); CGContextAddLineToPoint(context, self.xShift+15+self.rectLen*self.width+self.rectLen*(i+1), self.yShift+self.rectLen*10+self.rectLen); CGContextAddLineToPoint(context, self.xShift+15+self.rectLen*self.width+self.rectLen*i, self.yShift+self.rectLen*10+self.rectLen); CGContextAddLineToPoint(context, self.xShift+15+self.rectLen*self.width+self.rectLen*i, self.yShift+self.rectLen*10); CGContextMoveToPoint(context, self.xShift+15+self.rectLen

How to color manage AVAssetWriter output

China☆狼群 提交于 2019-12-02 04:10:09
I'm having trouble getting a rendered video's colors to match the source content's colors. I'm rendering images into a CGContext, converting the backing data into a CVPixelBuffer and appending that as a frame to an AVAssetWriterInputPixelBufferAdaptor. This causes slight color differences between the images that I'm drawing into the CGContext and the resulting video file. It seems like there are 3 things that need to be addressed: tell AVFoundation what colorspace the video is in. make the AVAssetWriterInputPixelBufferAdaptor and the CVPixelBuffers I append to it match that color space. use

How can I fix a Core Image's CILanczosScaleTransform filter border artifact?

怎甘沉沦 提交于 2019-12-02 04:07:16
I want to implement an image downscaling algorithm for iOS. After reading that Core Images's CILanczosScaleTransform was a great fit for it, I implemented it the following way: public func resizeImage(_ image: UIImage, targetWidth: CGFloat) -> UIImage? { assert(targetWidth > 0.0) let scale = Double(targetWidth) / Double(image.size.width) guard let ciImage = CIImage(image: image) else { fatalError("Couldn't create CIImage from image in input") } guard let filter = CIFilter(name: "CILanczosScaleTransform") else { fatalError("The filter CILanczosScaleTransform is unavailable on this device.") }

Any possible way to call drawRect from a UIViewcontroller class?

旧街凉风 提交于 2019-12-02 03:39:56
I have a UIViewController class called AppController.h , AppController.m . I have thousands of lines of code in there, and that is the only reason why I didn't test this before I asked it. Is there any possible way to use drawRect in a UIViewController ? that way I wouldn't have to make more delegates and methods and callbacks. I should have started off using drawRect to handle my drawing code, but I didn't, and there's severe lag with core graphics on the iPad. So, please let me know if there's any way to use drawRect in a UIViewController . Thanks! A view controller naturally has a pointer

Keep text on an image readable while rotating the image

痴心易碎 提交于 2019-12-02 03:34:52
I have an image view that looks like a wheel. This view detects touch events on each of the colored sections. The problem I have is that when I rotate this wheel, the UILabel s on top of the view need to also be rotated so that the text is still horizontal and human readable. What is the best way to rotate the labels while the parent view is being rotated? This is what I am trying now and it does not rotate correctly... CGAffineTransform textTransform = CGAffineTransformRotate(newTransform, newAngle * -1); Presumably you are applying a rotation transform to rotate the wheel. If the labels are

Memory management in Coregraphics (iOS)

 ̄綄美尐妖づ 提交于 2019-12-02 03:23:40
I am working on a drawing application, I am using CGlayers for drawing, So I open my canvas for drawing on click of a button, I am using UIBezierPath and then converting it to CGPath in touchesMoved below and then using it to draw -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { if (ctr == 4) { m_touchMoved = true; self.currentPath = [[DrawingPath alloc] init]; [self.currentPath setPathColor:self.lineColor]; self.currentPath.pathWidth = [NSString stringWithFormat:@"%f",self.lineWidth]; pts[3] = midPoint(pts[2], pts[4]);// move the endpoint to the middle of the line joining the

Circular UIView with multiple coloured border working like a pie chart

穿精又带淫゛_ 提交于 2019-12-02 03:23:29
I am trying to set a circular avatar of a player of a game with a piechart representation on the avatar's circular border. Player 1 - Wins 25% Lost 70% Drawn 5% cell.selectedPhoto.frame = CGRectMake(cell.selectedPhoto.frame.origin.x, cell.selectedPhoto.frame.origin.y, 75, 75); cell.selectedPhoto.clipsToBounds = YES; cell.selectedPhoto.layer.cornerRadius = 75/2.0f; cell.selectedPhoto.layer.borderColor=[UIColor orangeColor].CGColor; cell.selectedPhoto.layer.borderWidth=2.5f; cell.selectedBadge.layer.cornerRadius = 15; I have the UIImageView as a circle already with a single border colour. At