I have these codes:
UIImage * img = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:IMAGEURL]]];
[self.imageView setImage:img];
But the IMAGEURL contains a high resolution picture so it takes much time to load. Can I resize the image data smaller to load faster?
Any help will be appreciated.
Thanks.
No, in order to resize the image you should at least read it in once, so unless the server has a low-quality version for you, there’s nothing you can do.
Unless you’re brave and the image is JPEG: libjpeg has a function to read in images downsampled by a factor of 2, 4 or 8. E.g. for scale 1/8 it reads DCT blocks and takes only the constant component. But this will be a little more complex. Read time will be drastically reduced.
See iphone-reading-an-area-of-an-image about this as well.