quartz-graphics

Simple iPhone drawing app with Quartz 2D

I am making a simple iPhone drawing program as a personal side-project. I capture touches event in a subclassed UIView and render the actual stuff to a seperate CGLayer. After each render, I call [self setNeedsLayout] and in the drawRect: method I draw the CGLayer to the screen context. This all works great and performs decently for d...

Background in an iPhone Quartz CAAnimation

Whenever I am using a quartz animation the background of the animation is white. How can I change this to be a different color. This is the code I am using to produce the animation [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1.0]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:su...

Releasing CGImage (CGImageRef)

I'm curious if I'm following proper memory management with CGImageRef, which I'm passing through several methods (since it's CG object, I assume it doesn't support autorelease). Memory management with non-NSObjects and interaction with other NSObjects is still somewhat new to me. Here what I'm doing: I'm creating the CGImageRef inside ...

Clear CATiledLayers Cache When Changing Images

I have a UIScrollView with a single subview, a UIView backed by a CATiledLayer. All is working well with one exception: when I change images from one to another the CATiledLayer caches the previous images zoom levels. Scrolling around then displays the old image for a split second before the updated image loads. Is there any way to t...

Problems making an UIImageView opaque on the iPhone

Doing as little alpha blending as possible is an important performance consideration for table view cells on the iPhone. I have table cells that are largely comprised of one big image view. I have set the UIImageView to be opaque, in both Interface Builder and programmatically, but the CoreAnimation instrument still shows that it is bein...

iPhone Object Allocation, GeneralBlock-24 & GeneralBlock-48

Hi All, I'm finishing up my third iPhone App. Cleaning up code and such. I have 3 memory leaks after the launch of the application. These remain constant no matter what I do in the App (no more leaks). The issue is that my Net Object Allocation keeps growing up. There are two blocks in particulat, GeneralBlock-24 & GeneralBlock-48 that ...

How to make a subview tint a portion of the screen on the iPhone?

I would like to write a UIView subclass that, among other things, colors whatever's underneath it a certain color. This is what I've come up with, but it unfortunately doesn't seem to work correctly: #import <UIKit/UIKit.h> @class MyOtherView; @interface MyView : UIView { MyOtherView *subview; } @end @implementation MyView - (id)...

Drawing woes with CALayer.

First of all, im finding the iPhone online docs to be not-so-very thoroughly clear when it comes to the various ways of rendering a layer. I get the jist of it, but im not clear when to use which methods and which requires the layer to be added as a sub layer or not. My project started off trivially with me loading images and simply dra...

Difference between quartz2d on iphone and mac

There is difference between quartz2d on iphone and mac? where can i find a list of that? Every book i founded in amazon is dedicate to programming quartz on mac. ...

Quartz2D - Create CGBitmapContext passing NULL to data

Hi, It Seems possible to let Quartz using OpenGL for rendering if it takes care of the memory, so I create a CGBitmapContext passing NULL to data. At the end of drawing process I need a pointer to raw memory where the image is stored but CGBitmapContextGetData return NULL. Does someone have any suggestions? Thanks. T. ...

CGMutablePathRef Memory Management

Do I need to release a CGMutablePathRef when I'm done with it? If so, how? ...

How to draw a shape on top of a UIImage while respecting the image's alpha mask

I need a UIImageView that can draw itself in color or b/w according to a flag: BOOL isGrey; I'm trying to do it by drawing a black rectangle on top of the original image with the Quartz blendmode set to Color. This works except it doesn't respect the image's alpha mask. See illustration: Searching Google and SO, I found and tried...

Which is faster? Using Quartz & CGRects vs an array UIImageViews

Just wondering weather its faster, if you have lots (~several hundred to a thousand) 2D images, to use Quartz or an array of UIImageViews. Cheers! ...

Making pictures look inset.

Hi, I wonder if anyone has an idea how you have to transform an image such that it looks "inset" to the context? I need the effect for an application I am writing, but I am not sure what the exact workflow is to achieve the effect mentioned above. Best regards, heinrich ...

Disable redrawing of CALayer contents when moved (iphone)

I have a UIView with a large number of CALayers (~1000), each of which has a small image as its contents. This UIView is a subview of a scrollview (actually it's a subview of another view which is a subview of the scrollview). This draws relatively quickly at first (couple seconds). However when I scroll in the scrollview the frame ra...

NSBezierPath / Line Intersection / flatten

Hello, I'm currently porting my jruby/java2d Graph Drawing/Layouting application to macruby/cocoa. Therefore I need to get the intersection point of an open NSBezierPath with an closed NSBezierPath. In java2d I used the following trick. I flattened both paths and did a simple line intersection test for each segment. So is there a sim...

iPhone SDK - How do you make a UIView that responds to audio input?

I am developing an app that uses Core Graphics and Audio Queue Services to generate an image that changes with the input from the iPhone's mic.  Some sort of interaction between Core Graphics and Audio Queue Services is killing my frame rate, keeping it at about 10 fps no matter what I do.  Profiling with Instruments tells me that my pro...

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

Browser Plug-ins Not Loading in WebView Implementation

I have a Cocoa app that I'm trying to write which displays a webpage. This webpage has an embedded quartz composition in the background that plays and works when in Safari, but it does show in my Cocoa application (it just shows the missing plugin icon in the background instead). The weird thing is that it works on another computer that...

CGContextRectToClip

Hi, i'm using CGContextRectToClip(aContext, aRect), the new rect for clipping is a intersection between the previous rect and aRect. I used CGContextSaveGSState and CGContextRestoreState to restore the previous rect of clipping, but seems don't work. Clipping rect is part of state, i hope yes. ...