core-graphics

iPhone draw with Core Graphics over an image

Hello, On my iPhone app, I would need to draw a kind of full gauge with a dynamic indicator. I was thinking of using a gauge image (a .png, that I would draw in an external tool) without any indicator, and then draw the dynamic indicator on top of the image. I was thinking of using a UIView with this image in background and then then us...

How to draw an NSString with an specific height on to an perfectly matching bitmap?

I have an NSString like @"Hello World" and want to convert that into an bitmap with exactly 20 pixels height. The width of the bitmap should match the width of the text. I know there are some NSString UIKit additions that can draw text, but I don't know how to draw the text with an bounding box of exactly 20 pixels height (text fits per...

How to release this?

I'm creating an bitmap context, and in my code there is this: bitmapData = malloc(bitmapByteCount); context = CGBitmapContextCreate (bitmapData, pixelsWidth, pixelsHeight, 8, // bits per component ...

Must I cast this that way?

size_t pixelsWidth = (size_t)bitmapSize.width; Or is it totally fine to do without the casting to size_t? bitmapSize is of type CGSize... ...

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

Can I set the scaleFactor of an UIView when I want my drawing code in -drawRect to not waste too much memory?

I am drawing something into -drawRect of an UIView, and in this case I really want a certain amount of pixels. With the retina display, my view has a scaleFactor of 2.0 and when I draw something that is supposed to be 10 pixels heigh, it's actually 20 heigh. Is it okay to set the scale factor back to 1.0 to get a 1:1 mapping between poin...

Sequence of CAAnimations - layer returns to initial position between subsequent calls

Hello! I'm trying to create an endless animation of layer rotating slightly to the left, then slightly to the right and back. So I'm animating 10 degress to the left, then 20 to the right, then 10 to the left again. It works great on simulator, but on device the layer "shivers". It appears like it returns to its previous state every ti...

Is CGContextGetTextDrawingMode() a private API?

I'm using this sniplet to center strings that are drawn with CoreGraphics. I can't find any documentation on the function CGContextGetTextDrawingMode(). It's obvious what it does, but is this a private API that I should avoid? ...

PDF parsing library for iOS?

Hi All, I wonder if there is a higher-level library for parsing PDF files in iOS (iPhone, iPad, iOS version 3.2) ? Specifically I'm looking for functionalities such as I can highlight a word or a sentence of text in a page and also to read PDF hyper-links and act upon them. I've looked up CGPDFScannerRef and it looks like the built-i...

Why do I have to reposition this UIView by an arbitrary amount?

I am building an application that must add an overlay view once a scrollview is done zooming. I was having problems adding the overlay to the scrollview itself and keeping the position consistent, due to what I assume is the scrollview not being done zooming...no biggie...so I decided to add the overlay to the sharedApplication's keyWin...

iPhone/iPad draw pdf like iBooks?

Hello, Does anyone know how to use core graphics to draw a pdf like in iBooks. I can already draw a pdf page using core graphics but was curious how iBooks shows a lower quality view of each page so it loads fast and then when you stay on a page longer it renders it a full quality. This makes it able to open the pdf without having to ma...

Core graphics or opengl for paint app?

Hello folks, I've just started to sketch the features of an app containing a paint module. Such module will work like most painting apps, like Brushes or Colors; you'll have a brush, a pencil and a rubber, plus a numbers of colors. I am wondering whether I should use OpenGL or CoreGraphics for the drawing routines. I am quite inexperienc...

UIPopoverController without arrows?

Hi, I would like to know to make an UIPopoverController without arrows In fact I would like to simulate something like this: See that There is no arrows There is a title that is somehow inside of a expanded top border of the UIPopoverController and not inside of it like in the normal UIPopoverController. I assume this is not reall...

iOS Core Graphics PDF memory managment problem.

Hello, I'm reading PDF file, and then releasing it: CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), (CFStringRef)@"somepdf.pdf", NULL, NULL); CGPDFDocumentRef pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL); int pagesCount = CGPDFDocumentGetNumberOfPages(pdf); CGPDFDocumentRelease(pdf); But the memory is not...

PicHandle to CGImageRef

This project is a generic C++ plugin with core-graphics support. I am unable to convert a PicHandle to CGImageRef successfully. Saving off image from CFDataRef results in a bad image. if(pic) { Handle thePictureFileHandle; thePictureFileHandle = NewHandleClear(512); HandAndHand((Handle)pic,thePictureFileHandle); d...

kCGBlendModeClear doesn't clear, why?

Hello folks, I'm writing some lines of code to get acquainted with the basics of Quartz 2d. I am trying to draw and image an then clear it through the kCGBlendModeClear blend mode. Here's the code of my UIView subclass code, whose background color is set to orange through IB: - (void)drawRect:(CGRect)rect { UIImage *brush = [UIImag...

Draw portion of image in CGBitmapContext

I have created a CGBitmapContext of 256 x 256 and I have a CGImageRef that I want to draw into this context. My goal is to crop the image (and ultimately create tiles of an image), but if I use CGContextDrawImage, Core Graphics scales the image to fit the context. So the question is, how do I make sure that only a portion of the CGImage...

Stop drawing of CATiledLayer

Is is possible to stop CATiledLayer to draw (drawLayer:inContext)? It draws asynchronously and when i try to release CGPDFDocumentRef, which is used by CATiledLayer, the app crashes (EXC_BAD_ACCESS). That's my view: @implementation TiledPDFView - (id)initWithFrame:(CGRect)frame andScale:(CGFloat)scale{ if ((self = [super initWithF...

Create PDF from CSV on iPhone

An iPhone app which I am creating generates reports from a Core Data database as a CSV file, which can then be emailed so that the user may use that data elsewhere outside of the app. I would also like to offer the ability to generate the same reports as a PDF file (of course, with nicer formatting) allowing the user to immediately print...

Crash on CGPDFDocumentCreateWithURL

I get an EXC_BAD_ACCESS on this code: NSURL *pdfURL = [NSURL URLWithString:path]; pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL); CFRelease(pdfURL); 'path' is just an NSString path the the file I am loading from the documents directory. I have chanced to ensure the path is correct. I am also running on the simulator but I ...