Quantcast
Channel: iOS Dev Diary » UIImage
Browsing latest articles
Browse All 12 View Live

Image may be NSFW.
Clik here to view.

How to select a UIImage from the camera roll (and use it)

The UIImagePickerController can help us do this with ease. In this example we’ll instantiate an image picker and tell it what kind of image we want returned. We have a choice of using an edited...

View Article



How to save a UIImage

// let's save our image as a JPG NSData *imageData = UIImageJPEGRepresentation(chosenImage, 1); // get our home directory and add the save path and file name NSString *imagePath = [NSHomeDirectory()...

View Article

How to load a UIImage that we’ve previously saved

// first we get the path to our image NSString *imagePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/myImage.jpg"]; // now we can load and display the file like this...

View Article

How to display a UIImage from an NSURL

If you’re displaying images from the main iOS bundle, things are fairly straightforward: self.imageView.image = [UIImage imageNamed:@"Amy.png"]; But if you have an NSURL to your image then it’s not as...

View Article

How to convert a UIImage into NSData

You can store a UIImage (or an NSImage on Mac) as raw data. This can be useful if you’d like to save it in Core Data. Here’s how you convert a UIImage into NSData: NSData *imageData =...

View Article


How to preload images in iOS

When you’re displaying a UIImage in your view controller it’s hardly noticeable how long it actually takes for the engine to “draw” the picture. Lenoard van Driel has tested this and confirms it takes...

View Article

How to test the size of a UIImage (in bytes)

We can use NSData’s length method for this. Imagine your UIImage is yourImage: NSData *imageData = UIImageJPEGRepresentation(yourImage, 1); NSLog(@"Size of your image is %d bytes", [imageData length])...

View Article

Image may be NSFW.
Clik here to view.

How to save a UIImage in Core Data and retrieve it

Way simpler than I had thought: Core Data can save binary NSData objects – all we have to do is declare the attribute as “Binary Data” in our model. Optionally you can choose to “Allow External...

View Article


Image may be NSFW.
Clik here to view.

How to save a UIImage to the Camera Roll in iOS

The UIImage Class provides a method that can save an image straight to the Camera Roll. In this example, yourImage is a UIImage: // super simple saving UIImageWriteToSavedPhotosAlbum(yourImage, nil,...

View Article


How to take a screeshot in iOS programmatically

In iOS we can press the HOME and the POWER button together at any time and a screenshot of what’s currently being displayed will be saved to the Camera Roll as if by magic. If we wanted to do the same...

View Article

How to apply Blur Effects to images and views in iOS 8

Click to view slideshow. In iOS 8 there’s a new class called UIVisualEffect with which you can apply blur effects to entire views. Reading the Class Reference however you’d never figure out how. In a...

View Article

How to extract a UIImage from a video in iOS 9

Here are two ways to extract the first frame of vision and turn it into a UIImage. Both methods are from the generous Stack Overflow community. Both methods make use to the AV Foundation framework....

View Article
Browsing latest articles
Browse All 12 View Live




Latest Images