core-graphics

Fill a touch drawn path of CGPoints using OpenGL or CoreGraphics

I have a NSArray of points that make up a path. I can detect when it self-intersects. When this happens, I try to fill the path. First I used CoreGraphics, now I'm using openGl to draw a triangle array. Doesn't work well as you can see in the image. How do I fill only the circular area while leaving the "tail" alone? I was thinking of...

No effect of reordering sublayers

I have a UIView subclass that instantiates three sibling sublayers of its layer. Two of the sublayers have their content set to images files; and the third has a graphic drawn in the - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx method. The problem is that my drawing layer always appears behind the image layers. I...

Drawing a line in a custom UITableViewCell

I am custom drawing text into a custom UITableViewCell, but am struggling in working out how to draw a line to underline text. I am currently trying to do the following: CGContextMoveToPoint(context, pt.x, pt.y+sz.height); CGContextAddLineToPoint(context, pt.x+sz.width, pt.y+sz.height); but although the code gets called, nothing is a...

How do I draw a sprite on a background using Quartz and CGLayers?

Hi, I am a newbie in Quartz and I am fighting to understand this stuff apple say is very easy and straightforward. I have created two CGLayers: one for a fixed background and another one for a sprite. I want this sprite to move. Both the background context and the sprite context are drawn offscreen and I would like both to be seen on ...

imageWithCGImage and memory

If I use [UIImage imageWithCGImage:], passing in a CGImageRef, do I then release the CGImageRef or does UIImage take care of this itself when it is deallocated? The documentation isn't entirely clear. It says "This method does not cache the image object." Originally I called CGImageRelease on the CGImageRef after passing it to imageWit...

How to be notified of the Minimize button being pressed in an OSX Window?

N.B.: this relates to private (SPI) functions of the CoreGraphicServices framework. I am currently running a CGSConnection to the Windowserver as the UniversalController (with the Dock killed), and would like to know how I can be notified that a CGSWindow has had the yellow minimize blob clicked. Is there a notification event that I ca...

How to draw a dotted rectangle marquee on iphone?

How to draw rectangle something like this in iphone sdk using core graphics ...

How do I create a new image by drawing on top of an existing one using Quartz?

i have a view with uiimageview i assign this uiimageview image by camera..now i want to do some drawing onto image....using coregraphics.i want to do something like this... select an area by touching and drawing line when line joins something like circle or any shape..i want to change that particular area in to something else for example...

Saving and restoring CGContext

I'm trying to save and restore cgcontext to avoid doing heavy drawing computations for a second time and I'm getting the error : CGGStackRestore: gstack underflow. What am I doing wrong? What is the correct way to do this? - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); if (initialized) { ...

NSLog with CGPoint data

I have a CGPoint called point that is being assigned a touch: UITouch *touch = [touches anyObject]; CGPoint point = [touch locationInView:self]; I want to get the x coordinate value into my console log: NSLog(@"x: %s", point.x); When I use this, log output for this is: x: (null) I have verified that point is not null when this i...

how to create a path using coregraphics?

i want to create a path.something like i touch the screen and draw line in touchmove event.when line intersect from starting point.fill that path using any colour. now see in the image i've drawn a line.i just want to detect if line intersects again to start point.then fill that path with my own desired color.also i m using core graph...

How do I draw to the contentView of a UITableViewCell?

Hi there, I'm trying to draw a line on a custom UITableViewCell. When I draw inside the overriden drawRect and use the current graphics context I don't see anything. I know I can't see anything because the draw rect is drawing to the UIView and not the contentView. So my question is, how do I draw to the content view using CG? Say, gra...

how to sharp/blur an uiimage in iphone?

i have a view with uiimageview and an UIimage set to it.how do i make image sharp or blur using coregraphics? ...

how to erase some portion of uiimageview's image in iphone?

i have a view with uimageview and an image set to it. i want to erase image as something like we do in photoshop with an eraser.how do i achieve this.also how do i undo erase??? ...

how to get only pixels from inside a irregular shape from uiimageview in iphone?

i want to get only those pixels which are inside an irregular shape..using core graphics not openGL.here is an image where i have drawn an irregular shape. and here is the drawing code - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { if(drawLineClicked) { UITouch *touch = [touches anyObject]; ...

Strange malloc error with autoreleased UIImages of specified size

I am tracking down a strange bug. The bug manifests itself with the display of this message in the console log: BlurApp(5018,0xa00d6500) malloc: *** error for object 0x103b000: pointer being freed was not allocated This message pops in after execution has left my event loop. It seems to be happening when the autorelease pool is bein...

draw a line using core graphics when touch moves in iphone?

how do i draw line when moving finger across screen in iphone using core graphics. ...

How to draw a line with an arrow head?

I need to draw a line with an arrow head. How can i do this using Core graphics. Any help!!! ...

Formatting multi-line text on the iPhone

Hey guys, I need to display some text on multiple views loaded on a UIScrollView. It should be centered both vertically and horizontally. I did accomplish this with no problems using a UITextView, but now I need to perform a little bit of formatting in the middle of the text - some color changing and italics. My first try was to use a...

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

Hi there, When using an iPhone Objective C method that accepts CGFloats, 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 gener...