How can I load vector image directly with iPhone SDK? Just as UIImage loads bitmap images.
A:
You could try loading the image file into an NSData object and initialising the UIImage from there. Might look something like this:
NSString *path = [[NSBundle mainBundle] pathForResource:@"AnImage" ofType:@".ext"];
NSData *imgData = [NSData dataWithContentsOfFile:path];
UIImage *img = [UIImage imageWithData:imgData];
imnk
2009-12-24 13:40:20
From Apple's document, UIImage only supports bitmap image. Can I put vector images (such as SVG) in imgData?
MQ Gu
2009-12-24 15:27:37
UIImage only supports TIFF, JPEG, GIF, PNG, BMP, ICO, CUR, and XBM files: http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIImage_Class/index.html . Nothing more.
Brad Larson
2009-12-24 15:56:02
OK I hadn't realised that. thx Brad. Guess that voids my answer really but I'll leave it here in case it may be of use to others.
imnk
2009-12-24 16:07:47
+1
A:
As of iPhone OS 2.1, the iPhone's WebKit supports SVG graphics natively. You should be able to use a UIWebView to load the SVG element for display. This question provides some sample code for doing so.
Brad Larson
2009-12-24 16:02:25