core-graphics

Quartz 2D: CGColorSpaceCreateLab: Purpose of range parameter?

In Quartz 2D, the CGColorSpaceCreateLab() function takes a range parameter defined as follows: CGFloat range[4]: An array of 4 numbers that specify the range of valid values for the a* and b* components of the color space. The a* component represents values running from green to red, and the b* component represents values running fro...

Problem with drawing paths with Core Graphics - iPhone

Hi, I am trying to draw a map annotation in my app - very much like MapKit's MKAnnotationView, but without the mapkit. I have a problem with the ordering of the path for the view outline that I cant figure out. Image of results: http://img504.imageshack.us/img504/5458/screenshot20091010at703.png Code: CGFloat minx = CGRectGetMinX(cu...

Get size of image without loading in to memory

I have several .png images (ETA: but the format could also be JPEG or something else) that I am going to display in UITableViewCells. Right now, in order to get the row heights, I load in the images, get their size properties, and use that to figure out how high to make the rows (calculating any necessary changes along the way, since mo...

iphone change fill color of a shape drawn in context

I have drawn an enclosed shape using CGContext and filled a default color. I want to change the fill color on some event, how can I do that. There is only one enclosed shape in the context. ...

Writing YUV data into a CGContext

How can I write a YUV frame data into a CGContext? ...

Converting a NSString to a cString for use with CGContextShowTextAtPoint

Hi, I am drawing a String using CGContextShowTextAtPoint. Thus I need to convert my NSString I want to draw into c Strings. Unfortunately special symbols like the euro currency symbol are not correctly shown. CGContextSelectFont(currentContext, "TrebuchetMS", 15, kCGEncodingMacRoman); CGContextShowTextAtPoint(currentContext, 0, 0, [my...

CGBitmapContext get pixel value Leopard vs. SnowLeopard confusion

Im trying to draw specific colour rectangles into a CGBitmapContext and then later compare pixel values with the colour i drew (a kind of hit-testing). On Leopard this works fine but on SnowLeopard the pixel-values i get out are different to the colour values i draw in - i guess due to colorspace confusion and ignorance on my part. ...

Any examples of creating a dial?

I'd like to create a dial with similar behavior to some of the retro phone apps. These have a circular dialer that lets you spin it around with your finger. Any ideas how that is created or some links that discuss aspects of it? ...

Need help understanding "kCGErrorIllegalArgument: CGSUnionRegionWithRect : Invalid Region"

While running my application (which does a good bit of custom drawing) I get this error (it happens a good bit with no observable side effects, but I'd like to understand what's happening). <Error>: kCGErrorIllegalArgument: CGSUnionRegionWithRect : Invalid region <Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch ...

iPhone Performance Differences in Quartz Drawing vs. Pre-Baked Images (which I guess simplifies to Quartz vs. Quartz)

New to Quartz and I am curious on the drawing speeds of simple shapes, gradients, and shadows; specifically comparing Quartz drawing functions to Quartz image drawing on the iPhone. Say that I need to draw a filled, stroked, and shadowed rectangle. I'm assuming that importing a pre-baked rect as a PNG and drawing it using drawInRect: o...

NSString drawInRect overlaps all characters

I am attempting to fill some text with a gradient-fill, where by I set the text drawing mode to clipping, and then paint a gradient-fill. The problem is, whenever I set the text drawing mode to clip, every character of the text string is placed on top of each other, rather than being painted in a sequence to form a word - it is most biza...

Moving a UIView along a CGPath according to touch position

I have a line graph I've drawn in Quartz, and a UIView 'bubble' that I'd like to ideally pop up when the user touches the single plot line, and moves their finger along it. The bubble displays some extra graph information. I'd like to 'attach' the UIView to the CGPath plot, but I'm having trouble conceptually figuring out the best way t...

How to load PNG with alpha with Cocoa?

Hey guys, I'm developing an iPhone OpenGL application, and I need to use some textures with transparency. I have saved the images as PNGs. I already have all the code to load PNGs as OpenGL textures and render them. This is working fine for all images that don't have transparency (all alpha values are 1.0). However, now that I'm try...

Change Screen Resolution in Snow Leopard

I've been plugging away at this for a few hours now, and haven't found a good answer. In Leopard, I can programmatically change the screen resolution using Quartz Display Services with CGConfigureDisplayMode. Unfortunately, this has been deprecated in 10.6. This seems like a simple task: how can I change the screen resolution with non-d...

Generate PDF from html file on iPhone

In my iPhone application I'm generating an HTML file. I would like to convert that HTML file to a PDF file programatically. The PDF will then be attached to an email. Does anyone know (have an example) how to convert the HTML file to a PDF? ...

Cocoa-Touch: How to set the interpolation quality to be used by a UIImageView?

I have a UIImageView showing a image that is larger than it's frame. It's set to rescale the image to fit it's frame. But, the image is scaled with a low quality filter. I've read here that this is caused by it using a low interpolation quality. How can I get it's context to CGContextSetInterpolationQuality to kCGInterpolationHigh? ...

Get union of the frames of several transformed UIImageViews?

I've got a collection of roughly 10 overlapping UIImageViews. Each one is rectangular but each is rotated and scaled separately. Are there any Core Graphics tricks for drawing a path around the perimeter of ALL the images? CGRectUnion may give me a rectangle encompassing all the views (though I vaguely remember the frame is undefined o...

Overlaid images

I'm creating an application where I will be drawing two circles onto the screen, one large circle with a smaller circle inside. I want the user to be able to touch/drag on the screen inside or outside of the large circle and it will move the smaller circle in that direction. If the user touches outside of the large circle the smaller cir...

Where can I find examples of Quartz 2D drawing on the iPhone?

Hi, I am going to develope the 2D game in Iphone using Quartz. what is the main Difference between Quartz and QuartzCore? I have searched a lot over the internet, but only able to find out the MAC OS with Quartz Examples. If any body has any Link/URL for Examples of Quartz(2D) using Iphone Developement,which would be run in the Real ...

Resize UIImage with aspect ratio?

I'm using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:kCGBlendModePlusDarker alpha:1]; UIImage *tmpValue = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); Which is working g...