Вопрос

I get image data from NSURLConnection, and store the data using NSMutableData. The point is that I want to store a smaller size of the image.

Now I use the following code to get a smaller image:


    UIImage *temp = [[UIImage alloc] initWithData: imageData];
    image = [temp resizedImage:CGSizeMake(72, 72) interpolationQuality:kCGInterpolationHigh];
    smallImageData = UIImagePNGRepresentation( image);

My question is can I get smallImageData directly from imageData? As I think my method will cost a lot if I have numbers of connection to get the image data.

Это было полезно?

Решение

This is a correct method to downsize images. If this is in a tight loop, you can wrap it in an autorelease pool to make sure any temporary objects are collected.

If you are running into issues with memory then serialize your requests to run one at a time.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top