quartz-graphics

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

Tinting iPhone application screen red

I'm trying to place a red tint on all the screens of my iPhone application. I've experimented on a bitmap and found I get the effect I want by compositing a dark red color onto the screen image using Multiply (kCGBlendModeMultiply). So the question is how to efficiently do this in real time on the iPhone? One dumb way might be to grab...

UIImageWriteToSavedPhotosAlbum save as PNG with transparency?

I'm using UIImageWriteToSavedPhotosAlbum to save a UIImage to the user's photo album. The problem is that the image doesn't have transparency and is a JPG. I've got the pixel data set correctly to have transparency, but there doesn't seem to be a way to save in a transparency-supported format. Ideas? EDIT: There is no way to accomplish ...

Impossible to post-produce the image from the iPhone camera?

On an iPhone 3GS, the image captured by the camera has 2048x1536 pixels. If my math is correct, opening this image on a CGLayer will consume 12.5 MB. Springboard will terminate any application that reaches beyond 12 mb (at least this is what happens to me). Manipulating this image with a function like CGContextDrawLayer will consume an...

Creating PDF with CGContextDrawPDFPage Fails with white text

I'm trying to merge multiple PDFs, i'm copying one-by-one all pages into PDF, but the pages have white color text. means text are not in displayable manner. counld you help..? Thanks In advance...! My Function to Merge PDF: -(void)mergePDFs:(NSArray*)pdfList{ CGContextRef pdfContext; CFStringRef path; CFURLRef url; CFMutabl...

Issue with Annotation Views disappearing on double tap zoom

I've ran into a problem with annotation views in the MapKit on the iPhone. I manage to draw custom annotation views on the map - no problem there. I even manage to redraw them after dragging or zooming. However, there are cases where the redrawing does not work: an example would be double-tap zoom. I attach some code where I draw a few ...

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

Background of UILabel visible after a composite.

I am doing something a bit unusual. I'm trying to tint all the components in my application red (you may have seen some other postings from me about this, but this is something more specific). To do so, I'm intercepting all calls to CALayer's drawInContext: and after calling the original method, I composite red onto the layer using kCG...

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

Drawing a rounded drop shadow with Quartz

I am trying to draw a drop shadow underneath an image to which I apply rounded corners, but I have 2 problems: The drop shadow only appears underneath the non-rounded area of the rounded image and not underneath the bottom rounded corners as one would get if applying a drop shadow in photoshop. Using the same settings as in photoshop (...

Fast, 2 Dimensional Table View

I'm implementing a view for displaying tabular information with 2 axis, but I'm starting to run into performance issues with rendering all the cells. The view looks something like this: +------------+-------------+------------+------------+------------+ | | 12.00am | 1.00am | 2.00am | 3.00am | +------------+-...

Snap to grid effect with Quartz 2d? iphone dev

Hi there, Still an iphone dev starter but trying. I would like to have the user touch the screen at which point a pin (dot) will be placed on the view. I have accomplished this (yey) but i would like to have snap to grip effect, and can not come up with a solution. This is how i am placing that dot: CGPoint drawPoint = CGPointMak...

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

How to clear and then redraw a quartz drawing

I'm making a complex drawing using quartz based on passed in information. The only part I haven't been able to figure out is how do I clear the lines, rectangles, etc that I've already drawn? Basically, I want to erase the whole drawing and just draw it again from the new data. ...

Comparing colors in Objective-C

Hi! I'm trying to determine if two colors are equivalent, using code written in Objective-C. I'm using this snippet of code to determine if the two colors are equivalent (currently for debugging purposes) NSLog(@"currentColor is %@", currentColor); NSLog(@"Adjacent Color is %@",[[buttonArray objectAtIndex:1] backgroundColor]); NSLo...

UIView using Quartz rendering engine to display PDF has poor quality compared to original.

I'm using the quartz rendering engine to display a PDF file on the iphone using the 3.0 SDK. The result is a bit blurry compared to a PDF being shown in a UIWebView. How can I improve the quality in the UIView so that I don't need to rewrite my app to use the UIWebView. I'm using pretty much close to the example code that Apple provid...

UITabBarController-like image masking effect

I'd like to recreate the effect that the UITabBarController is doing with images in the tab bar, using exactly the same images. I've futzed around with a number of ideas using masking, but I haven't come up with anything satisfactory. Anyone have a recipe for doing this? ...

iPhone Dev: Pocket God Used Graphic Engine

I want to develop a 2d game. I have to choose from Quartz/CoreGraphics, OpenGL ES or Cocos2D. I'm interested in how the game Pocket God is realized because it fulfills perfectly my needings. Do you know which technology is used to build the game Pocket God? ...

iphone sdk: Creating an image of the contents of the screen?

Hi guys, I'm looking for a way to write the contents of the screen to an image. Any idea how to achieve that? Does it involve using Quartz? Thanks ...

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