core-graphics

How do I draw repeatedly (over time) into the same UIImage? (Or whatever backing store I need to make?)

I'm about at my wit's end over this issue, due to hitting a good dozen other website (as well as this one) looking for a straight-forward answer to my problem... First off, I'm trying to figure out a way, given a starting image created via [UIImage imageNamed:] to add decorations based on processing over time. (Think of a heat map.) I...

CGAffineTransformMakeRotation makes image border distorted in iphone

Hi, I am using CGAffineTransformMakeRotation to roatate my image that is palced in UIImageView. But I have noticed that when i move the image it makes the image border look blur and distorted. Below is my code for the same UIImageView1.image = [UIImage imageNamed:@"sample.png"]; albmImageView1.transform = CGAffineTransformMakeRotati...

iphone interface events resolve on exit

I'm having trouble getting components added through the Interface Builder to work on the iPhone. It works perfectly in the simulator, but not on the device. When debugging I found that the events are handled on exit, instead of when i actually press the button. Anyone else run into this issue? edit: after some investigation, it turns ou...

Is there a way to force Interface Builder events to resolve?

i'm having issues where if I use draw commands in a UIView::drawRect method, components created through Interface Builder will not resolve their events. Is there a way to force events to resolve, kind of like how you can force a draw by calling [self setneedsdisplay]. yes, i'm having problems clicking on buttons and switches. the events...

Applying a texture to stroke a CGContextStrokePath

I am working on making a simple drawing program. So far I am able to stroke the path with a given color and that all works out fine. I was wondering if there was a way to stroke it with a texture instead of a color. Say for instance I want to give the path the look of a pencil line. Any idea on how I would go about doing that? Thanks in...

Is it possible to save an image with Core Graphics on the iPhone?

The following code converts a PDF page into a JPEG. It runs as expected on Snow Leopard: ... //get the image from the bitmap context CGImageRef image = CGBitmapContextCreateImage(outContext); //create the output destination CGImageDestinationRef outfile = CGImageDestinationCreateWithURL(fileUrl, kUTTypeJPEG, 1, NULL); //add the image ...

Alternative for sizeWithFont: method

Hi! I have a class which work is to parse a text into several pages. I use sizeWithFont: method to identify when one page ends and another starts. But unfortunately since the amount of text which needs to be parsed is pretty big, whole operation needs to be performed on a background thread (takes several second to complete). And therefo...

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

get the UIImage (or CGImage) from drawRect

I'm calling the following code from drawRect - (void) drawPartial:(UIImage *)img colour:(UIColor *)colour { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState(context); CGContextTranslateCTM(context, 0.0, self.bounds.size.height); CGContextScaleCTM(context, 1.0, -1.0); CGContextDrawImage(c...

Fog drawing using Core Graphics

I know that OpenGL has functionality that allow fog drawing. But, how to draw fog (smoke) using Core Graphics? Is this hard task? And, what concepts for implementing this task? ...

Drawing an offscreen coloured square returns a greyscale image

I asked this question earlier and am now trying to explore the idea of making an offscreen image. Something is going wrong - I think maybe with colour space? I've boiled the code down and down and down, until I eventually can demonstrate the problem with just a few lines. I have a view with an imageview (called iv) and a button, which...

iPhone SDK: Rendering a CGLayer into an image object

Hi all, I am trying to add a curved border around an image downloaded and to be displayed in a UITableViewCell. In the large view (ie one image on the screen) I have the following: productImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:product.image]]; [productImageView setAlpha:0.4]; productImageView.frame = CG...

iPhone: How to Maintain Original Image Size Thoughout Image Edits

hi, I am developing an iPhone app that resizes and merges images. I want to select two photos of size 1600x1200 from photo library and then merge both into a single image and save that new image back to the photo library. However, I can't get the right size for the merged image. I take two image views of frame 320x480 and set the v...

Drawing a Shadow after the CGContextClip with Core Graphics

UPDATE: I tried implementing the method specified by Peter and am getting incorrect shadowing. What is wrong? CGContextSetShadowWithColor(c, CGSizeMake(4, 4), kAudioThumbShadowBlur, [[UAColor blackColor] CGColor]); CGContextFillPath(c); CGMutablePathRef path = CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, minx, mid...

Drawing CGPathRef in ScrollView using Iphone sdk.

Hi all. I want to draw some curve in my scroll view using CGPathRef. I tried to draw this path but i see only the part of my CGPathRef which located at 320x480 pixels. Is it way to do that. Thank you in advance. Here is my code path = CGPathCreateMutable(); CGContextBeginPath(ctx); CGContextMoveToPoint(ctx, [[pathArray objectAtInd...

Do I have a memory management problem in here?

Something must be wrong with this code right here: + (UIImage*)captureView:(UIView *)theView { UIGraphicsBeginImageContext(theView.frame.size); [theView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return newImage; ...

Optimal pixel format for drawing on iPhone?

Pretty simple question: when doing some pretty intense drawing with CoreGraphics on the iPhone, how can I specify the pixel format to get optimal performance? Is the format that I get from the context via UIGraphicsGetCurrentContext per definition the best one? I know that RGB565 is supposed to be the fastest to use in OpenGL. Does that ...

How to achieve the same effect like the unlock slider in the welcome screen of iPhone OS?

I need to do something similar, where an animation highlights the text of a button to show that it must be slided to do something. Just like that unlock thing on the iPhone. How is that done? Is there a tutorial how to achieve this effect? ...

CGRect in C code

A simple google search for: CGRect + C or CGRect in C brings back only Apple, iPhone, and Objective-C websites. However, I remember hearing that Core Graphics was part of C at my university. Did I hear incorrectly, or is CGRect something that I can use in C, or even C++ as it's Object oriented? ...