Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Reduce Resolution UIImageView

stylodevstylodev Posts: 1New Users
edited May 2013 in iOS SDK Development
I've created a UIImageView which contains an image with a high resolution. The problem is that the resolution of that image is too high to put into the imageView, because it looks now pretty ugly. The size of the imageView is 92 x 91 (so it's small). It contains an UIImage, whose resolution is too high so it looks ugly in the UIImageView.
So how can I reduce the resolution of that UIImage

My code for the UIImageView:
UIImageView *myImageView = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:pngFilePath]];
    myImageView.frame = CGRectMake(212.0, 27, 92,91);
Tagged:

Replies

  • Duncan CDuncan C Posts: 9,116Tutorial Authors, Registered Users @ @ @ @ @ @ @
    You can create a graphics context at whatever size you want, render your image into it, and then extract the contents into an image. That code is easy. However, you are going to capture a small, ugly image. (It will look about the same as the way it looks when you render your large image into the tiny 90x90 image view.) The main advantage to shrinking your image is to save on memory.

    To create an off-screen graphics context the methods you need are UIGraphicsBeginImageContext and UIGraphicsGetImageFromCurrentImageContext.
    Regards,
    Duncan C
    WareTo

    widehead.gif
    Animated GIF created with Face Dancer, available for free in the app store.

    I'm available for one-on-one help at CodeMentor
Sign In or Register to comment.