cgcontext

Static background for CGContext

梦想与她 提交于 2019-12-07 11:28:35
问题 this is my first question here, so hello everyone. I have spent some time now wrapping my mind around the following problem and could not come up with a solution. I'd be happy if someone could point me in the right direction. I'm using CGContext to draw various layers of graphical representations of live data which should be refreshed at a reasonable framerate of at least 50fps. I want to use a static image as a background. Re-drawing this image using the context for every cycle significantly

iPhone clear CGContext

浪子不回头ぞ 提交于 2019-12-07 06:46:40
问题 I create a circle with a nice shadow with this code (I use MonoTouch.net for iPhone, Objective-C answers are fine of course) UIGraphics.PushContext (ctx); SizeF shadowSize = new SizeF (0f, -3f); ctx.SetRGBFillColor (194f / 255f, 212f / 255f, 238f / 255f, 1f); ctx.SetAllowsAntialiasing (true); ctx.SetShadowWithColor (shadowSize, 20, new CGColor (0.9f, 0.7f)); RectangleF area = new RectangleF (35f, 15f, 210f, 210f); ctx.FillEllipseInRect (area); UIGraphics.PopContext (); Then I want to add to

How to create embossed or shadow effects using Core Graphics (for finger paint)

北战南征 提交于 2019-12-07 05:09:41
问题 I have issue to implement "Emboss/Shadow effects" in my drawing. Finger paint functionality is currently working fine with my custom UIView and below is my drawRect method code: Edit code with all methods : - (void)drawRect:(CGRect)rect { CGPoint mid1 = midPoint(previousPoint1, previousPoint2); CGPoint mid2 = midPoint(currentPoint, previousPoint1); CGContextRef context = UIGraphicsGetCurrentContext(); [self.layer renderInContext:context]; CGContextMoveToPoint(context, mid1.x, mid1.y);

Remove alpha channel from UIImage

℡╲_俬逩灬. 提交于 2019-12-07 04:45:05
问题 I use the following method to get a decompressed uiimage from file system. However the UIImageView is colored as red when I turn on the color blended layer, even though the UIImageView is set to Opaque. The images on file system don't have alpha channel. I tried set CGContextSetAlpha(bitmapContext, 1), but still has blended layer. Anyone know how to remove alpha channel when using CGContextDrawImage? - (UIImage *)decompressedImage { CGImageRef imageRef = self.CGImage; CGRect rect = CGRectMake

iOS开发CoreGraphics核心图形框架之二——深入理解图形上下文

限于喜欢 提交于 2019-12-06 19:31:53
iOS开发CoreGraphics核心图形框架之二——深入理解图形上下文 一、引言 在上一篇博客中,介绍了有关CGPath绘制路径的相关方法,其中在View视图的drawRect方法中,已经使用过上下文将Path路径绘制到当前视图上,上一篇博客只是抛砖引玉,本片博客将更深入的介绍下有关上下文的更多内容。关于接胡搜啊CGPath应用的博客地址如下: iOS开发CoreGraphics核心图形框架之一——CGPath的应用: https://my.oschina.net/u/2340880/blog/757072 。 二、关于图形上下文Graphics Context GraphicsContext对于开发者来说是完全透明的,开发者不需要关心其实现,也不需要关心其绘制方式,开发者只需要将要绘制的内容传递给图形上下文,由图形上下文来将内容绘制到对应的目标上。这个目标可以是视图,窗口,打印机,PDF文档或者位图对象。需要注意,绘制的顺序在CoreGraphics框架中十分重要,如果后绘制的内容和先绘制的内容有位置冲突,后绘制的内容将覆盖先绘制的内容。 特定的上下文用于将内容绘制到特定的输出源上,CoreGraphics中提供如下几种图形上下文: 1.位图图形上下文:位图图形上下文用于将RGB图像,GMYK图像或者黑白图像绘制到一个位图(bitmap)对象中。 2.PDF图形上下文

Merging two images of different size with rotate and zoom

三世轮回 提交于 2019-12-06 18:56:35
I'm facing the following problem : I have to merge two images bottomImg and topImg to create a new image C as a result of the merging. I already know how to merge two images but in this case my goal is a little bit different. top image may be zoomed and rotated. I have follow this answer . But in this solution top image is cut while i rotate. simulator actual stored image is document like I have try this code _parentViewGIf for bottomImg and for _ivGIF for topImg - (UIImage *)mergeImage:(UIImage *)bottomImg withImage:(UIImage *)topImg { float width=bottomImg.size.width*_ivGIF.frame.size.width/

How to make the different colour appearance while layer color of the view is changing

邮差的信 提交于 2019-12-06 13:03:59
问题 I am doing some custom download progresses bar in side the (subclassed) UIButton (or) i can also do that in UIView , every thing is fine, now i want change the colour of the title as the progress the proceeds, for example as u can see in the below image shows what is now i am getting, what i want is like below image i want change the color of the title to white or some other color as download proceeds, is there any way i can do, any sample code for this. i am achieving this by using below

How to draw a triangle shaped UIButton

99封情书 提交于 2019-12-06 10:41:59
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! First use a CAShapeLayer to create a mask CAShapeLayer * shapeLayer = [CAShapeLayer layer]; //Use these to create path CGMutablePathRef path = CGPathCreateMutable(); // CGPathMoveToPoint // CGPathAddLines shapeLayer.path = path; Then set mask of your button yourbutton.layer.mask = shapeLayer yourbutton

kCGTextStroke's Fill and Stroke aren't positioned correctly

让人想犯罪 __ 提交于 2019-12-06 09:23:06
So I'm using the code below to apply a stroke (and fill) to text in a UILabel , and it's coming out like the image below. The stroke is heavier on one side than the other (look at the top of the letters compared to the bottom, and the right compared to the left. The period at the end makes it very noticeable, too, looks like a googly eye). I've not got any shadowing turned on at all, so I don't think it's the shadow interfering with the stroke. What could be causing this? - (void) drawTextInRect: (CGRect) rect { CGContextRef c = UIGraphicsGetCurrentContext(); CGContextSetTextDrawingMode(c,

How to get rid of this “points” between my lines when I am drawing?

谁说我不能喝 提交于 2019-12-05 23:35:37
问题 is there an easy way to not draw this points in my lines? I don't know why this points are there because i never release my finger from screen during drawing of a line. I got the code from a drawing example. // draw a line - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { mouseSwiped = YES; UITouch *touch = [touches anyObject]; CGPoint currentPoint = [touch locationInView:self.view]; currentPoint.y -= 0; // 20 only for 'kCGLineCapRound' UIGraphicsBeginImageContext(self.view