Reputation: 1614
I want to create an iOS app that contains a uiimageview and a button so that when a user hits a button the image view is generated by a set of 2 nested while loops that set the pixels for the uiimageview. i can do this in C with a bitmap quite easily but I'm not sure how to approach this for iOS could I save a bitmap to NSUserDefaults and load it from there? Not sure, thanks for the help.
Upvotes: 0
Views: 657
Reputation: 15213
UIImageView
works with UIImage
, which is a UIKit
's wrapper for CGImage
. In any case you should have either a CGImage
or UIImage
. What can you do? Draw an image dynamically using CoreGraphics and/or UIKit's drawing methods (take a look at Quartz2D Programming Guide). Or if you can have a raw byte data of your image you can directly create an UIImage
instance:
NSData *imgData = [[NSData alloc] initWithBytes:(const void*)myByteArray length:sizeof(myByteArray)];
UIImage *img = [[UIImage alloc] initWithData:imgData];
then just set your UIImageView
's image
property:
self.myImageView.image = img;
Upvotes: 2