core-graphics

How To Remove Line in Core Graphics

旧街凉风 提交于 2019-12-08 04:51:07
问题 I draw a line using CGContextAddLineToPoint in my app now i want to remove line from given points how can i do this i am using touches for drawing line 回答1: You can erase, Given the two points, draw the line with same attributes(lineWidth etc.,) by setting the CGContextSetBlendMode(context, kCGBlendModeClear) . 来源: https://stackoverflow.com/questions/10601691/how-to-remove-line-in-core-graphics

Drawing a rectangle on UIImageView using Core Graphics

大兔子大兔子 提交于 2019-12-08 03:31:25
问题 I want to let the User to draw a rectangle on UIImageView I added two variables for first an last touch locations I added this function:- func draw(from: CGPoint, to: CGPoint) { UIGraphicsBeginImageContext(imageView.frame.size) context = UIGraphicsGetCurrentContext() context?.setStrokeColor(UIColor(red: 0, green: 0, blue: 0, alpha: 1.0).cgColor) context?.setLineWidth(5.0) let currentRect = CGRect(x: from.x, y: from.y, width: to.x - from.x, height: to.y - from.y) context?.addRect(currentRect)

Producing CCITT compressed TIFF from CGImage

怎甘沉沦 提交于 2019-12-08 03:06:20
问题 I have a CGImage (core graphics, C/C++). It's grayscale. Well, originally it was B/W, but the CGImage may be RGB. That shouldn't matter. I want to create a CCITT-Group 4 TIFF. I can create an LZW TIFF (grayscale or color) via creating a destination with the correct dictionary and adding the image in. No problem. However, there doesn't seem to be an equivalent kCGImagePropertyTIFFCompression value to represent CCITT-4. It should be 4, but that produces uncompressed. I have a manual CCITT

How to encode UIBezierPath to SVG?

感情迁移 提交于 2019-12-08 02:53:51
问题 I have a simple view for finger painting / drawing. I store the drawings as UIBezierPath s in a NSMutableArray . Now I want to transfer the drawings to a web-service for presenting them in a browser. Therefore I need to encode my UIBezierPath s in a SVG-file - because this the format of the web-service. What I found right now is the SVGKit, which only DECODES SVG. Do anybody know sample code, snippets or a framework for encoding SVG? Thank you. 回答1: I tested yet. but using following steps:

How to add Image at the particular area in a template image

无人久伴 提交于 2019-12-08 02:47:59
问题 This is a template image (http://i.stack.imgur.com/9ME6A.jpg) in which multiple circular area are available. we need, when we click on any circular area (one by one ) then gallery should be open and after selecting the image from gallery that image should be shown on the selected circular area. Please provide me any link or demo for my problem. i am stucking here. Thanks! 回答1: Make a viewController with 5 "UIImageView" views. Arrange as you need it Place there your smile images. Add

RGB Data from CGImage in Swift

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 00:21:38
问题 I've tried to build reading RGB pixel data in Swift. Getting the basic Image Information is no problem, but I think I've got something wrong with the pointer and the byte-offset: let provider:CGDataProviderRef = CGImageGetDataProvider(inImage) let data:NSData = CGDataProviderCopyData(provider) let bytes: COpaquePointer = data.bytes // Needs to be changed to ConstUnsafePointer<()> in xCode beta3 let bytePointer = UnsafePointer<UInt8>(bytes) println("Pixel Data:\n") var printString:String = ""

High-performance copying of RGB pixel data to the screen in iOS

♀尐吖头ヾ 提交于 2019-12-07 23:58:32
问题 Our product contains a kind of software image decoder that essentially produces full-frame pixel data that needs to be rapidly copied the screen (we're running on iOS). Currently we're using CGBitmapContextCreate and we access the memory buffer directly, then for each frame we call CGBitmapContextCreateImage, and then draw that bitmap to the screen. This is WAY too slow for full-screen refreshes on the iPad's retina display at a decent framerate (but it was okay for non-Retina-devices). We've

How to create a CGPath from a file — i.e. SVG

前提是你 提交于 2019-12-07 21:45:17
问题 Is it possible to create a CGPath from a given file? SVG would be preferred, but anything will work. 回答1: PocketSVG will turn an SVG file into a UIBezierPath from which you can get a CGPath: PocketSVG *myBezier = [[PocketSVG alloc] initFromSVGFileNamed:@"BezierCurve1-iPad"]; UIBezierPath *myPath = myBezier.bezier; //myPath.CGPath <--- your CGPath 回答2: Seems like there is a more clever solution SVGKit: SVGKit is a Cocoa framework for rendering SVG files as Core Animation layers. All shapes are

iOS - Fill Animation of a UIBezierPath from bottom

半腔热情 提交于 2019-12-07 21:35:54
问题 I have a UIBezierPath inside custom UIView , draw() . I want to fill that path, lets say a rectangle from bottom to top. How can I implement this. From Here I have seen using CAShapeLayer its possible. That is working fine with animation but filling is not happening from bottom to top on the rectangle. Please guide. 回答1: Is this what you are asking for? func zoom() { let startPath = UIBezierPath(rect: CGRect(x: 0, y: self.frame.size.height-30, width: self.frame.size.width, height: 30)) let

How to draw a triangle shaped UIButton

家住魔仙堡 提交于 2019-12-07 21:35:29
问题 I really dig the IFTTT bottom right corner button, as shown in the image (bottom right). I tried playing around with CGContext and UIBezierPath to match the effect, but i simply don't know enough to get this right. Does anyone have some thoughts/code on how to make this happen? Thanks! 回答1: First use a CAShapeLayer to create a mask CAShapeLayer * shapeLayer = [CAShapeLayer layer]; //Use these to create path CGMutablePathRef path = CGPathCreateMutable(); // CGPathMoveToPoint // CGPathAddLines