NemeSys
NemeSys

Reputation: 555

Large images loaded in iOS and resized by outlet

I'm working with iOS and images that sizes full iphone screen (depending of the resolution of device).

I have to create a toolbar with many of these images as thumbnails, but I've only as resource the full size image.

My question is if I load every image as UIButton Background, and the button is resized to in example, 68x68px, the amount of memory allocated by the pictures is the same as if they are loaded in full resolution?

I've to give a compression treatment to these images before?

Thanks.

Upvotes: 1

Views: 350

Answers (1)

QED
QED

Reputation: 9923

I think the memory management question depends on a number of details which you haven't provided. For example: how many times in your code do you load the image? If you use [UIImage imageNamed:@"bigImage"] more than once, then iOS will happily oblige and load the image again. But if you just do that once, and use the UIImage object many times, then you will only have one copy of the image in memory.

As for how much memory the button itself uses, I don't know. My guess is that it's either not adding anything to the memory footprint of your app (beyond the underlying UIImage object), or only that memory necessary for a 68x68 screen buffer.

All of this being said, if I were in your situation, I would probably just create the smaller, button-sized images myself as part of development, and include them in the app. This will also I think yield efficiency benefits at runtime. If you are resizing your button dynamically, then perhaps your approach will work, but I'd still give it some scrutiny from a design standpoint - dynamically-resizing buttons is uncommon.

Upvotes: 2

Related Questions