core-graphics

RGBStroke - Image pixels instead of color (iOS)

狂风中的少年 提交于 2019-12-24 19:09:55
问题 I am implementing a image mask kind of feature in iOS similar to what is offered in the Blender app with two images. Here is my touch move code :- - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint currentPoint = [touch locationInView:staticBG1]; UIGraphicsBeginImageContext(view.frame.size); [image_1 drawInRect:CGRectMake(0, 0, view.frame.size.width, view.frame.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(),

How to copy one CGContextRef to another?

房东的猫 提交于 2019-12-24 19:07:06
问题 in -drawRect: , I created a secondary CGContextRef using CGBitmapContextCreate() . When I'm done with this context, I need to copy it's contents over to the "original" context of -drawRect:. How can I do that? Reason why I create an additional context: I hope to get CGContextClipToMask() to work in a view that has a transparent background. My idea is to do all the mask-drawing and clipping in another context that has the appropriate color (non-transparent, no alpha), and then somehow paste

Save UIImage as 8-bit Grayscale Bitmap

核能气质少年 提交于 2019-12-24 17:31:21
问题 I am trying to output a UIImage to an 8-bit grayscale bitmap, but I'm not very familiar with image manipulation, so I am at a loss on how to do this. I followed this stackoverflow post (Objective C - save UIImage as a BMP file) to create a UIImage category which can successfully generated a RGB 32-bit image, but I have been unable to manipulate the code to get it to output it in 8-bit grayscale. I am trying to get the raw bytes for this image in order to pass on to a provided C library. Does

Unable to get rid of spike on bezier path

拥有回忆 提交于 2019-12-24 16:40:38
问题 I'm drawing some simple bezier paths, but I'm finding it impossible to remove the spikes created when the angle between line segments is small: (Note: The circle is from a separate drawing operation, but I'm trying to make sure the line does not spike past the circle...). I've tried all kinds of variations of lineCapStyle and lineJoinStyle but nothing seems to work. In addition to what is shown below I have tried using a Miter Join with 'setMiterLimit'. Here's my line drawing code snip:

Stretch Drawn Shape to fit Frame?

我的未来我决定 提交于 2019-12-24 14:28:02
问题 I have an app where I'm drawing a special ellipse I made a via series of Bezier Paths as follows: CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState(context); CGMutablePathRef pPath_0 = CGPathCreateMutable(); CGPathMoveToPoint(pPath_0, NULL, 515.98,258.24); CGPathAddCurveToPoint(pPath_0, NULL, 515.98,435.61,415.54,515.98,258.24,515.98); CGPathAddCurveToPoint(pPath_0, NULL, 100.94,515.98,0.50,435.61,0.50,258.24); CGPathAddCurveToPoint(pPath_0, NULL, 0.50,80.86,100.94,0

How to get points of Arc?

假如想象 提交于 2019-12-24 14:05:03
问题 I am working on core animation and core graphics.I am drawing one arc with centre (0,0).Now i want to draw line after arc.i can draw arc but then after i am not able to get two different point of arc.How can i get it?Here is code : CGMutablePathRef retPath = CGPathCreateMutable(); CGPathMoveToPoint(retPath, NULL, 20, 0); CGPathAddLineToPoint(retPath, NULL, 75,10); CGPathAddArc(retPath, NULL, 75, 10, 20, 240, 360, YES); return retPath; Please help me.Thanking you.Hint will also be appreciated.

How to release a CTFramesetter?

不问归期 提交于 2019-12-24 11:12:01
问题 I am using CoreText in my app and i have a really huge leak but i cant fnd out why it happens. so here is the snippet of my code: _framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)_mAttributedString); CFDictionaryRef frameOptionsDictionary = (CFDictionaryRef)[self frameOptionsDictionary]; _frame = CTFramesetterCreateFrame(_framesetter, CFRangeMake(0, _mAttributedString.length), path, frameOptionsDictionary); CFRelease(_framesetter), _framesetter = NULL; As you can

Is there any performance or memory overhead using UIImage or UILabel or NSString in Quartz2D

纵然是瞬间 提交于 2019-12-24 10:23:08
问题 Is there any performance or memory overhead using UIImage or UILabel or NSString in Quartz2D . If there is no difference then why not use UIImage , UILabel etc. Can any one send me the snippet how to draw image without using UIImage . Thanks in advance, Regards. please correct me if you see any stupid mistake I am new to this, trying to learn it. 回答1: A label draws a string. You can't have a label without a string; if you did, what would it draw? Last I checked, UILabel uses UIWebView

Mirroring UIView

雨燕双飞 提交于 2019-12-24 09:59:10
问题 I have a UIView with a transparent background, and some buttons. I would like to capture the drawing of the view, shrink it, and redraw (mirror) it elsewhere on the screen. (On top of another view.) The buttons can change, so it isn't static. What would be the best way to do this? 回答1: Check a nice sample code http://saveme-dot-txt.blogspot.com/2011/06/dynamic-view-reflection-using.html following WWDC sessions. It uses CAReplicatorLayer for reflection, pretty easy to implement and looks

32 bit/component Images with CGImageCreate are actually only 8 bit/component

[亡魂溺海] 提交于 2019-12-24 09:09:13
问题 For the past 4 to 5 hours I've been wrestling with this very bizarre issue. I have a an array of bytes which contain pixel values out of which I'll like to make an image of. The array represents 32 bit per component values. There is no Alpha channel, so the image is 96 bits/pixel. I have specified all of this to the CGImageCreate function as follows: CGImageRef img = CGImageCreate(width, height, 32, 96, bytesPerRow, space, kCGImageAlphaNone , provider, NULL, NO, kCGRenderingIntentDefault);