quartz-2d

clipping a UIImage as per a polygon

How can I let the user of my iphone app to clip a UIImage by a dynamically generated CGPath. Basically I display a rectangle overlaid on a UIImageView and the user can move the 4 corners of the rectangle to get a polygon with 4 sides. The rectangle is not filled so you see four lines overlaid on an image. The user should be able to clip...

mixing opengle es and quartz 2d - performance cost?

The apple docs say it's possible but does anyone know if there is a performance hit when say drawing a quartz path on top of images loaded with opengl es? Or, mixing drawing of paths from both etc? Thanks. ...

Draggable objects in Cocoa

Hi all, I am completely new to objective c and have an quite ambitious project I want to create. One of the things I'll need to do is have a drawing layer, where I can have a circle in the middle, and be able to drag other circles near it to attach them, and then be able to move them around, changing their position around the initial c...

How do I programmatically provide a glossy look to UIButtons?

I would like to add 3D or glossy look to some iPhone UIButtons, but do so without the use of PNGs or stretchable images. I have a lot of buttons of varying shapes and sizes with lots of colors which are generated on the fly, so prerendered images are not feasible in my case. How would you go about drawing the gloss on these buttons pro...

UIImage+Resize.h - wrong affine transformation given for UIImageOrientationUp orientation

For the UIImage resize I used the following class. http://iphone.svn.wordpress.org/trunk/UIImage+Resize.m But I am having issues in some iPhone orientation where I keep the phone in lined with a vertical surface. It does the resize properly but the image is not properly affine transformed. The image orientation is different. I logged t...

How to obtain a CGImageRef from the content of an UIView?

I have an UIView where I was drawing some stuff inside -drawRect:. Now I need a CGImageRef from this graphics context or bitmap of the UIView. Is there an easy way to get that? ...

Saving a PDF document to disk using Quartz.

Hello, I am trying to draw a pdf page onto a pdf context and then save it to disk. I cannot seem to figure out what is wrong. Can someone give me a few pointers. Thanks. - (void)testQuartz:(NSData *)pdfDocumentData { //Create the pdf document reference CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((CFDataRef...

CGContext line drawing: CGContextFillPath not working?

Anyone have any idea why CGContextFillPath won't work in the code snippet below? I'm using the following code to draw to a UIImageView. It's stroking the path correctly, but ignoring CGContextFillPath. UIGraphicsBeginImageContext(self.frame.size); [drawingView.image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.heig...

Learning Quartz

What's a good book for learning Quartz in Objective-C? I thought about buying this book: Quartz 2D however, a reviewer said it's written mainly in C (I only know ObjC). So does anyone have any recommendations? ...

How to keep the previous drawing when using Quartz on the iPhone?

I want to draw a simple line on the iPhone by touching and dragging across the screen. I managed to do that by subclassing UIView and change the default drawRect: method. At the same time in my viewcontroller I detect the touch event and call the [myView setNeedsDisplay] when necessary. The problem is that when I try to draw the second l...

Quartz 2D Experts -- Masking method crashes program after 6 or 7 consecutive calls

Hi all, I'm looking for a Quartz 2D expert that might be able to see a flaw in the following code: self.imageView.image = [self maskView:self.imageView withMask:[self createMaskForTool:self.toolView modifyForOutline:NO]]; - (UIImage *)maskView:(UIView *)view withMask:(UIImage *)maskImage { UIGraphicsBeginImageContext(view.bound...

Curve text on existing circle

For an application I am building I have drawn 2 circles. One a bit bigger than the other. I want to curve text between those lines, for a circular menu I am building. I read most stuff about curving a text that you have to split up your text in characters and draw each character on it's own with the right angle in mind (by rotating the ...

Implementing a main menu for iPhone game - how to get back to the Main Menu ?

Hi all, Apologies for the long post and I hope it makes some sense to someone out there. I have written an iPhone game (in Quartz 2d) which uses the following structure : App delegate loads a view controller called gameviewcontroller and its associated view In the "View did load" method, the gameviewcontroller starts up and initiates...

Problem adapting scale factor for iPad x2 compatibility mode

Hi all, I wonder if anyone can help me with following. I have written a Quartz 2d ap and have used the following code to get the correct scale factor for each device : if ([UIScreen instancesRespondToSelector:@selector(scale)]) { return [[UIScreen mainScreen] scale]; } else { return 1.0; } I then multiply all values b...

Is it possible to inject a CIBumpDistortion filter to a specific area of the screen on Mac OS X (Snow Leopard)?

I want to temporarily distort the area under the mouse using a CIBumpDistortion to increase the visibility of the mouse pointer. At the moment, I have a transparent-background NSWindow that floats around under the pointer and shows a cross-hair that fades in when you move the mouse, and out when you stop. This is working okay, but a Bu...

Splitting one main UIView into Multiple UIViews for Sprite Drawing (Quartz 2d)

Hi all, I currently have a game which uses one single UIView to draw a number of sprites onto the screen in its drawrect method every game tic. I have been advised that for performance it would be better to separate out each sprite into it's own UIView. My questions are : Structurally how does this work ? Do I create one UIView and t...

Quick Check re How To Implement Multiple UIViews in an iPhone Game

I am going to restructure my game to use multiple uiviews. Is the following flow correct ? I create 6 uiviews ( one for each sprite). game loads root uiview. root uiview init method loads 5 subviews using self addSubview. in the game controller I update each uiview each game tic. the game controller will need a pointer to each Uivie...

PDF creation on iPhone: <Error>: invalid Type1 font: unable to stream font

Hi! I'm creating a PDF on the iPhone and this works almost brilliant. I just get one annoying error in the console when I draw text: <Error>: invalid Type1 font: unable to stream font I'm using the following code to do the text drawing: [title drawInRect:textRect withFont:[UIFont fontWithName:@"Helvetica-Bold" size:16]]; I've tri...

How to integrate Quartz 2d drawing into a UIView subview ?

Hi all, I have a drawrect method in my main UIView which draws 8 sprites every game tic. I want to seperate out each of these sprites into a seperate UIView. I am trying to split out one sprite first as a test. So far I have added a UIView as subview to my main view and set it's frame. This draws a black box on the view. My question i...

Change PDF metadata on iPhone using Quartz 2d

Hi all! How can I change the metadata of a PDF using Quartz 2d on iPhone? That's the way I get the CGPDFDictionaryRef: CFDataRef pdfDataRef = (CFDataRef)pdfData; CGDataProviderRef providerPDF = CGDataProviderCreateWithCFData(pdfDataRef); CGPDFDocumentRef pdfDocumentRef = CGPDFDocumentCreateWithProvider(providerPDF); CGPDFPageRef page...