lostInTransit
lostInTransit

Reputation: 70997

iPhone - save image at higher resolution without pixelating it

I am using the image picker controller to get an image from the user. After some operations on the image, I want the user to be able to save the image at 1600x1200 px, 1024x1024 px or 640x480 px (something like iFlashReady app).

The last option is the size of image I get in the UIImagePickerControllerDelegate method (when using image from camera roll)

Is there any way we can save the image at these resolutions without pixelating the images?

I tried creating a bitmap context with the width and height I want (CGBitmapContextCreate) and drawing the image there. But the image gets pixelated at 1600x1200.

Thanks

Upvotes: 1

Views: 1214

Answers (3)

nielsbot
nielsbot

Reputation: 16022

Before drawing try adjusting your CGBitmapContext's antialiasing and/or interpolation quality:

CGContextSetShouldAntialias( context, 1 == 1 )

CGContextSetInterpolationQuality( context, kCGInterpolationHigh ) ;

If I remember right, antialiasing is turned off on CGContext by default.

Upvotes: 1

Corey Floyd
Corey Floyd

Reputation: 25969

This is non-trivial. Your image just doesn't have enough data. To enlarge it you'll need to resample the image and interpolate between pixels (like photoshop when you resize an image).

Most likely you'll want to use a 3rd party library such as:

http://code.google.com/p/simple-iphone-image-processing/

This performs this and many other image processing functions.

Upvotes: 2

swingfuture
swingfuture

Reputation: 1108

From faint memories of computer vision class from long ago, I think what you do is to blur the image after the up-convert.

Upvotes: 1

Related Questions