cgcontext

How to draw nil using cgcontext

I want to draw nil instead of the colors, because in the end I want the code to erase a section of the UIImageView in order that you can see what is behind the UIImageView. - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint currentPoint = [touch locationInView:self.v...

iPhone clear CGContext

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....

Setting A CGContext Transparent Background

I am still struggling with drawing a line with CGContext. I have actually go to line to draw, but now I need the background of the Rect to be transparent so the existing background shows thru. Here's my test code: (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColo...

How can I get color space from a CGContext?

I want to create a bitmap CGContext with the same color space as an existing CGContext. How can I get the color space of a CGContext? ...

I am trying to clear the currently drawn image on the cgcontext

I have drawn a uiimage on a cgcontext CGContextDrawImage(tempContext, CGRectMake(0,0,myRect.size.width,myRect.size.height), imgRef); but once user is done with the current image, i want to clear the tempContext so that I can rescale / manipulate the image and redraw it on the same context. for this i want to clear the the context and...

iPhone: Crash While Drawing CGLayers Stored in Array

I'm trying to build a drawing app with redo and undo functionality. My idea is to draw lines in a layer in "touchMoved", then saving the layer in "touchEnded". I'm not shure that I am drawing to the layer correct, everything works fine though, until I clear the image I'm drawing in on and try to redraw the layers in the array. - (void)...

CGContextSetShadow produces no results

I'm using this code in my UIView subclass to draw a circle with a gradient fill: - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetShadow (context, CGSizeMake(4,4), 5); CGContextBeginPath (context); CGContextAddEllipseInRect(context, CGRectMake(self.bounds.origin.x, self.bo...

What is the relation between a CGContextRef and a UIView?

While I was going thru the pdf document in quartz 2D, they were saying about getting a page from the CGPDFDocument object. Then the draw the page in a CGContextRef object. CGPDFDocumentRef document = MyGetPDFDocumentRef (filename); CGPDFPageRef page = CGPDFDocumentGetPage (document, pageNumber); CGContextDrawPDFPage (myContext, page);...

When is -[UIView drawRect:] Method Invoked?

Is it invoked just before the main view is going to be shown Can we call it whenever we want? ...

Is there a way that I can make a program like GLPaint using CGContext?

I want to make a program similar to GLPaint using CGContext that is very smooth and easy to put images behind. I understand that GLPaint has no allowance for putting an Image behind the painting canvas, rather than having just a black one. ...

How would I draw this using CGContext

I want to draw this in my view to draw this line, I have everything I need to make a basic line, but am just not good at drawing, I did in fact try to do this, but just cannot get it to work correctly. ...

Could someone please show me how to create a CGPattern that I can use to stroke a path with an image?

I want to stroke a path using a .png that I have but I just don't know hot to make a CGPatternRef. ...

How would I draw something like this in Core Graphics

I want to be able to draw using this as my stroke. How would I do this as efficient as possible, and on the fly drawing, I was thinking CGPatternRef, but I really don't know how to do that. Edit: It does not need to warp to the path. I just coultn't fix that issue in Illustrator. ...

Drawing triangle/arrow on a line with CGContext

Hi, I am using the framework of route-me for working with locations. In this code the path between two markers(points) will be drawn as a line. My Question: "What code should I add if I want to add an arrow in the middle(or top) of the line, so that it points the direction" Thanks - (void)drawInContext:(CGContextRef)theContext { ...

iPhone Graphic is distorted until a view is opened on top of it and dismissed

I have a scroll view within which I am creating a graphic with CGContext commands. When it is first displayed everything is slightly larger than should be and fuzzy. If I present another view on top of the graphic with presentModalViewController and dismiss it, the graphic corrects itself. Any suggestions? Thanks, John ...

CGContextDrawImage returning bad access

Hello guys, I've been trying to blend two UIImage for about 2 days now and I've been getting some BAD_ACCESS errors. First of all, I have two images that have the same orientation, basically I'm using the CoreGraphics to do the blending. One curious detail, everytime I modify the code, the first time I compile and run it on device, I g...

Iphone SDK quesiton: How to make a Drawing method in a View class work using CGContextRef?

I have these 2 methods in the View class. the drawRect method always gets called when the view is initalized. But i can't get the drawLine method to work. It doesn't do anything when it gets called. Am i supposed to deal with cgimagecontext or something like that? please help!! - (void)drawRect:(CGRect)rect { // Drawing code // ...

iPhone: How to use CGContextConcatCTM for saving a transformed image properly?

I am making an iPhone application that loads an image from the camera, and then the user can select a second image from the library, move/scale/rotate that second image, and then save the result. I use two UIImageViews in IB as placeholders, and then apply transformations while touching/pinching. The problem comes when I have to save bo...

Quartz Composer in iPhone UIView

Hi everyone, I am trying to embed a Quartz Composer document in an iPhone app. I know Quartz Composer support was added in iPhone OS 3.1 (at least, that's what Wikipedia says) but I can't find any good resources on how to do this. Do I use CGContext? Or are there more friendly ways to add a Quartz Composer composition? Thanks! ...

Will it use more and more memory if I keep drawing on the UIView?

This is my drawRect: CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 2.0); CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor); CGContextMoveToPoint(context, x1, y1); CGContextAddLineToPoint(context, x2, y2); CGContextStrokePath(context); If I run this code thousand times or mo...