Frage

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.

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top