core-graphics

iPhone app 3d engine or not

I am developing a simple iPhone app, which: retrieves data from the server presents the data In order to present the data better I want to add nice 3d dynamic objects, for example: a car with spinning wheels next to car sales bar chart. power plant with smoke coming out of the chimney next to CO2 emission numbers The questions a...

Merging paths in Core Graphics?

I've drawn two circles that overlap. I want to be able to fill and stroke them as a merged new shape. At the moment, I create the path sequence once, stroke it, then create a copy of it, fill it and add the two identical paths on top of each other, so they appear as a single shape. Is there a better approach or is this ok? Update: Her...

How to implement NSGraphicsContext in iphone.

CGContextRef ctx; NSGraphicsContext *nsGraphicsContext; nsGraphicsContext = [NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:NO]; [NSGraphicsContext saveGraphicsState]; [NSGraphicsContext setCurrentContext:nsGraphicsContext]; There is no NSGraphicsContext for iphone. Thus CGContextRef context= UIGraphicsGetCurrentCo...

Getting a screenshot of a UIScrollView, including offscreen parts

I have a UIScrollView decendent that implements a takeScreenshot method that looks like this: -(void)takeScreenshot { CGRect contextRect = CGRectMake(0, 0, 768, 1004); UIGraphicsBeginImageContext(contextRect.size); [self.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurre...

Problems saving PDF files in iOS4

I want to have my iPhone application create a PDF file and store it in an appropriate place - probably the iBooks folder so it can be easily retrieved using iTunes, but that's a change for later once I have the saving part working. I've followed the PDF saving tutorial on the Apple site to the letter, including swapping out CGContextBegi...

How to access the Overlay object boundingMapRect at the OverlayView?

Hi All, I'm trying to place images on top of Google Maps and I'm having trouble to fetch the overlay's boundingMapRect. The odd thing is that when I check the 'overlay' with the debugger the correct data is there, but when I try to print it - its garbage. This is the printing code: MKMapRect overlayRect = [self.overlay boundingMap...

How to create a CGPath from a file — i.e. SVG

Is it possible to create a CGPath from a given file? SVG would be preferred, but anything will work. ...

Memory warning removes UINavigationBar buttons

I've overridden drawLayer:inContext: on UINavigationBar in a category so that I can put a custom image up there. I hate it, but my client was adamant. As a result, I've had to fall back to some pretty ugly hacks to get things up there. I had to put a new method in that category to put a title on the nav bar header, and I have to call it...

unable to allocate 4 buffers of 20 mb of memory in app on ios 4 but could in ios 3

I wrote an app compiled against ios 3 that would easily allocate up to 100 mb of memory for image processing purposes. However, when that same app was compiled against the ios 4 sdk, I found that it crashed when many apps were open in the background. When I kill the background apps, the application then runs fine. I reduced the memory us...

Why is CGImageCreateWithMaskingColors() returning nil in this case?

When I use the following code: UIImage *image=[UIImage imageNamed:@"loginf1.png"]; CGImageRef rawImageRef=image.CGImage; const float colorMasking[6] = {222, 255, 222, 255, 222, 255}; CGImageRef maskedImageRef=CGImageCreateWithMaskingColors(rawImageRef, colorMasking); maskedImageRefis always nil. Why is this, and what can I do to co...

Draw part of CGImage

I have an application that draws images from a CGImage. The CImage itself is loaded using a CGImageSourceCreateImageAtIndex to create an image from a PNG file. This forms part of a sprite engine - there are multiple sprite images on a single PNG file, so each sprite has a CGRect defining where it is found on the CGImage. The problem i...

How can I draw a page of a PDF, excluding a particular image?

I have working code that will draw a page of a PDF. Now I would like to exclude a bitmapped image that appears on that page (but continue to draw the formatted text). I understand that I can use a CGPDFScanner to scan the contents of the PDF. Is there a way to write those contents into a new PDF, but skip any bitmapped images? Or is the...

How to make a line draw between two points as you are trying to set the second / end point of the line (like drawing a line in MSPAINT!)

I was wondering if anyone would be able to tell me how you would go about this? e.g. - User pushes (+) Add Button - Image appears to let user set start point of line - After user sets the first point a second image appears and a line is drawn between them and animated between them as user moves the second image into place. You could s...

CGPDFDocumentCreateWithURL is giving me 0x0 nil

Hello, I have file test.pdf in my Application Bundle. I run test in iPhone Simulator (iPad) and I cannot get the CGPDFDocumentRef populated. Am I going crazy or what?!? here is a piece of code from the sample application made especially for this (ViewController class): - (void)viewDidLoad { [super viewDidLoad]; // below code to...

achieve Image filter like other image editing apps have in iphone?

Hello all, I am new to image processing and also in openGL and CoreImage,coreGraphics Libraries. I want to create a basic image editing app with these functionalities. Rotate,crop,resize,scale, along with these filters Black and white,sepia,night vision,colour dithering. What is the best approach openGL or coreGraphics? Any help regardin...

Partial pdf page rendering on CATiledLayer

I'm using CATiledLayer to render a heavy pdf page inside a UIScrollView that is used to handle zooming and spanning.. The method below is called every time a Tile need to be drawn and I regret that I have to paint the whole pdf every time. I hope that behind the scene the CATiledLayer only render the part that it needs but nothing is l...

KVC: How do I save UIKit structs in plist?

I am using KVC to set properties of objects from a plist. I know I can save them as strings <string>{{66, 114}, {64, 64}}</string> and manually convert to structs, but how can I save for example a CGPoint or CGRect in a plist in a way that Cocoa KVC would understand? The Key-Value Coding Programming Guide seems to indicate that I need to...

CoreGraphics slower on iPhone4 than on 3G/3GS

I have a chart drawn with CoreGraphics. This chart can be scrolled horizontally and it's drawn as we scroll it. The problem is that on 3G/3GS the speed and performance of the scroll is good but on iPhone 4 is slower than expected. I suppose this is a issue related to the higher resolution of the iPhone 4. Is that correct? How can I i...

transparency/alpha in CoreGraphics context (iphone, objc)

Hello, I am currently making a basic image editor for iphone. I take the CGImageRef from a UIImage and create a context for it using the following code origImage = result.CGImage; Iheight = CGImageGetHeight(origImage); Iwidth = CGImageGetWidth(origImage); IcolorSpace = CGColorSpaceCreateDeviceRGB(); IrawData = malloc(Iheight * Iwidth...

Seeing malloc allocating large chunks of memory - trying to track down why (iPhone)

I'm seeing my app being killed by iOS with an out of memory message, however, while tracing the progress of the app in the Allocations Instrument, I see lots of mallocs that seem to be occurring outside of the code I've written. I'm not seeing any leaks being caught, so I assume these allocations are supposed to be there. Thing is, beca...