core-graphics

Using Core Graphics to paint a custom 'tab top' label

I've been coding with the iPhone SDK for nearly a year now and managed, up til now, to avoid Core Graphics. My question might therefore look quite simplistic. I need to implement a class that resembles a real-world 'folder tab'. Here's a mockup .. I've been getting by with UILabel, and have tried to subclass it, implementing a drawRe...

How to draw Truncated text with ATSUI.

Hi, How do i draw truncated text with ATSUI?? I have a legacy app which uses QuickDraw API. it uses StringWidth , TruncString and DrawString functions. I could replace the StringWidth and DrawString with ATSUI's ATSUMeasureTextImage and ATSUDrawText. However i could not find a way to truncate a string so that it fits into a rect. I use...

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

ipad, sdk, CGBitmapContextCreate

Hi, right now im working on an application that accepts cgimageref, process the pixels of the image and returns the processed cgimageref. To check how it works i simply wrote a code to pass the cgimageref and expects the same image to be returned with out being processed. But the problem is that im not getting back the exact image. the r...

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

Optical character recognition on the iPhone

Is it possible on an iPhone app to take a picture and extract an string from the picture? We'd like to make our app to look for a serial number on a database (very long number) without the user having to type it. Is there any Cocoa/Objective-C API for this or any C/C++ library that can be used in an iPhone app? Thanks in advance! ...

Using CGContextDrawTiledImage at different zooms causes massive memory growth

I'm working on app an where there's a view in a zoomable UIScrollView. When the user zooms in or out, I redraw the view that's in the UIScrollView to be nice and sharp. That view has a background image that I draw with CGContextDrawTiledImage. I noticed that memory usage grows every time I switch to a new zoom level. It looks like CGCon...

Ternary Raster Operations in Mac OS X and/or iOS?

I am looking to implement a mechanism that combines bitmaps together in a variety of complex ways, using ternary raster operations like you can in Windows. The idea is to be able to blt an image to a destination using any kind of combination of the source, brush, and destination pixels (source AND destination, source AND brush AND desti...

CGContextDrawPDFPage memory leak

I have used CGContextDrawPDFPage two times in my project. One is for displaying the PDF and the other is for making the thumb image of the PDF. I am using the PDF to image code from http://github.com/0xced/pdfrasterize/blob/master/CGPDFAdditions.c I am calling the PDF to image method like this in my code NSURL *url = [NSURL fileURLW...

Does CGContextDrawImage decompress PNG on the fly?

I'm trying to write an iPhone app that takes PNG tilesets and displays segments of them on-screen, and I'm trying to get it to refresh the whole screen at 20fps. Currently I'm managing about 3 or 4fps on the simulator, and 0.5 - 2fps on the device (an iPhone 3G), depending on how much stuff is on the screen. I'm using Core Graphics at ...

Most efficient way for partially drawing an UIView in drawRect:

I'm using setNeedsDisplayInRect: as much as possible in my UIView subclass, but I don't know what to do in drawRect:. What is the best way to detect which parts of the UIView have to be drawn? Right now I've divided my UIView into several CGRect's. For each CGRect I'm calling CGRectContainsRect() to check whether that CGRect needs to be ...

Creating UIView with layer from Application Delegate

Starting off with a default "View based" application I create a new view (ViewToDisplay, class that inherits from UIView) and inside this view I create a layer (LayerToDisplay). The view draws something around the perimeter of the frame, and so does the layer but this time with dotted lines. This is to show / prove that the layer covers ...

Context made using UIGraphicsPushContext does not show rendered images

I am using UIGraphicsPushContext to push a context inside drawRect like so: - (void)drawRect:(CGRect)rect { // Create Bitmap Graphics Context UIContextRef ctxt = //blah blah; // Push the custom context in the graphics stack UIGraphicsPushContext(ctxt); // Draw Stuff // Get Image from custom context } My problem is that th...

CoreGraphics Multi-Colored Line

I have the following code the only seems to use the last colour for the whole line..... I want the colour to be changing throughout this. Any ideas? CGContextSetLineWidth(ctx, 1.0); for(int idx = 0; idx < routeGrabInstance.points.count; idx++) { CLLocation* location = [routeGrabInstance.points objec...

CGPointApplyAffineTransform giving negative values

Hi, I have a CGPointApplyAffine which is giving me negative values such as -161 for x and -58 for y. Are these values possible? Or am I using it incorrectly? CGPoint rotatedCenter = CGPointApplyAffineTransform(subview.center, self.transform); Thanks! ...

Poor performance loading a scroll view

Hi, I have a view controller whose view consists of a paged scroll view controlled by 2 buttons (previous and next). In this scroll view are several custom views, each the size of one page. When I load the main view, the scroll view is set up to contain all of these subviews. The performance of my app is currently unacceptable in thi...

Learning Core Graphics

I'm doing iPhone programming and I need to learn about Core Graphics. It looks Apple doesn't provide a programming guide for Core Graphics and I'm having hard times following the code that uses Core Graphics. Do you suggest any reference or book for learning Core Graphics? ...

Iphone convert color image to 2bit image (black-white)

Hi, I have been poundering this for the last few days.. I need help to convert a color image to "black and white", not grayscale. I what to do this with the iPhone SDK and Core Graphics, as i'm convinced this is possible. Thanks in advanced.. ...

Core Graphics state management

In some code snippet - (void) drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx { CGContextSetFillColorWithColor(ctx, [[UIColor darkTextColor] CGColor]); UIGraphicsPushContext(ctx); ... the current fill color is set, then the state is pushed to the stack. Other snippet: - (void) drawLayer:(CALayer *)layer inContext:(CGCon...

drawLayer:inContext is not called

I have my very own minimal view class with this: - (void) awakeFromNib { NSLog(@"awakeFromNib!"); [self.layer setDelegate:self]; [self.layer setFrame:CGRectMake(30, 30, 250, 250)]; self.layer.masksToBounds = YES; self.layer.cornerRadius = 5.0; self.layer.backgroundColor = [[UIColor redColor] CGColor]; [self s...