core-graphics

CoreGraphics rounded corner thickness

Whenever I stroke a path with rounded corners on iPhone, the rounded corners are thicker than the rest of the stroked path. See here for what I mean: Not sure why this happens, any ideas? ...

Drawing triangle/arrow on a line with CGContext

Hi, I am using the framework of route-me for working with locations. In this code the path between two markers(points) will be drawn as a line. My Question: "What code should I add if I want to add an arrow in the middle(or top) of the line, so that it points the direction" Thanks - (void)drawInContext:(CGContextRef)theContext { ...

How can we change color of a text programmatically ?

My code is -(UIImage *)addText:(UIImage *)img text:(NSString *)text1 { int w = img.size.width; int h = img.size.height; CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate(NULL, w, h, 8, 4 * w, colorSpace, kCGImageAlphaPremultipliedFirst); CGContextDrawImage(cont...

How to create a screen that let user to draw a 'sketch' through finger touch?

Hi I am developing an app which will let users to 'draw' on screen via finger touch - so basically users can write, draw shapes - similar to a white board. The problem is I am a newbie as far as iphone graphics programming is concerned, I would highly appreciate if community here provide some sample code link or suggest a direction as w...

HiShape leak or crash when releasing

Hello. I use HiShape as a "Region" class with coregraphics. Class: class CCGRegionMember { protected: HIMutableShapeRef m_ShapeRef; public: CCGRegionMember(); virtual ~CGRegioMember(); public: void Union(const Rect }; Constructor : CCGRegionMember::CCGRegionMember() { ResetMembers(); m_...

How to access pixels of an NSBitmapImageRep?

I have an NSBitmapImageRep that is created like this: NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:waveformSize.width pixelsHigh:waveformSize.height ...

Using a CALayer in UITableViewCell

On each cell of my table view I want to have a bar that the user can slide out from the right. On the bar I plan to have icons. So, to do this I subclassed UITableViewCell. On the cell I have implemented drawRect and in there I have already drawn a gradient and background color on the cell. From there, I can create a CALayer, give it...

Clipping/Masking UISearchBar (or another built in control)

I'm trying to clip/mask a UISearchbar as seen in the image. I know it's possible to clip views in general, but I was having some trouble doing it with a built in control such as this one. Any help would be appreciated. http://dl.dropbox.com/u/1006208/clipped_searchbar.png ...

How to draw an animatable ruler with Quartz2D?

I'd like to draw the lines of a simple ruler with Quartz2D, just for practice. Since I have no idea about doing vector graphics programmatically on the iPhone, maybe someone can point me to a good tutorial to get started? ...

CoreGraphics on iPhone. What is the proper way to load a PNG file with pre-multiplied alpha?

For my iPhone 3D apps I am currently using CoreGraphics to load png files that have pre-multiplied alpha. Here are the essentials: // load a 4-channel rgba png file with pre-multiplied alpha. CGContextRef context = CGBitmapContextCreate(data, width, height, 8, num_channels * width, colorSpace, kCGImageAlphaPremultipliedLast | kCGBi...

Turning an NSImage* into a CGImageRef?

Is there an easy way to do this that works in 10.5? In 10.6 I can use nsImage CGImageForProposedRect: NULL context: NULL hints: NULL If I'm not using 1b black and white images (Like Group 4 TIFF), I can use bitmaps, but cgbitmaps seem to not like that setup... Is there a general way of doing this? I need to do this because I have an ...

How to write text on graph x and y-axis intervals points?

I developed graph using NSObject class and using CGContext method. The following code displaying dynamically in X and Y-axis intervals, CGContextSetRGBStrokeColor(ctx, 2.0, 2.0, 2.0, 1.0); CGContextSetLineWidth(ctx, 2.0); CGContextMoveToPoint(ctx, 30.0, 200.0); CGContextAddLineToPoint(ctx, 30.0, 440.0); for(float y =...

iPhone CALayer Stacking Order

I'm using CALayers to draw to a UITableViewCell. I'm trying to figure out how layers are ordered with the content of the UITableViewCell. For instance: I add labels to the UITableViewCell in my cellForRow:atIndexPath method In the drawRect method of UITableViewCell I draw some content using the current context Also, in drawRect I add...

CGGradient in an CGPath

Is it possible to draw a gradient in a path on the iPhone? I'm looking for a replacement of the mac os x method -drawInBezierPath:(NSBezierPath *)path relativeCenterPosition:(NSPoint)relativeCenterPosition of NSGradient. ...

How do I draw lines and rectangles on the iPhone?

I would like to draw a line and rectangle in my iPhone application, for that i want to used structure concept to draw line and rectangle.In strut shall i want to be struct line { float X1; float Y1; float X2; float Y3; color of line draw line function }; And similarly in case of rectangle. struct rect { float left X1; float top Y1; flo...

Does Quartz2D test intersection of rect by line before drawing it.

I'm drawing a big scheme that consist of a lot of lines. I do it in the drawRect: method of UIView. The scheme is larger than the layer of view and I check each line and draw it only if it intersects the visible rect. But at one moment I thought, should I do this? Maybe Quartz is already doing this test? So the question is: When I use f...

Optimizing drawing on UITableViewCell

I am drawing content to a UITableViewCell and it is working well, but I'm trying to understand if there is a better way of doing this. Each cell has the following components: Thumbnail on the left side - could come from server so it is loaded async Title String - variable length so each cell could be different height Timestamp String ...

About updating a View using in iPhone using Objective C.

I have a scene, called testScene, it works like this: @interface testScene : myScene { IBOutlet UIView *subview; IBOutlet UIView *drawingCanvasView; IBOutlet UIButton *update; } - (void)updateDrawingCanvas: (id) sender; and when the user click the button, update, it will run the updateDrawingCanvas method. So, I have a drawingCan...

How to draw a drop shadow AND gradient with quartz2d?

Hello! I've a custom shape drawing using coregraphics and i want to add a drop shadow and a gradient to it also. I've been trying and searching a lot of informations on how to combine and do this, but i can't get it to work. I'm able to draw only one either. Anyone doing this already or know how to do this? Thank you. ...

Rendering UIImage/CGImage into CGPDFContext results in... blankness!

Hi all, I'm trying to take an image that I have in a image object and render into a Core Graphics PDF context-- happens to be on an iPhone but this question surely applies equally to desktop Quartz. This UIImage is a simple color-on-white image at about 600x800 resolution. If I (say) turn it into a PNG file, that file looks exactly as ex...