应用程序大小太大,因为图像太多 [英] App size is too big because of too many images

查看:183
本文介绍了应用程序大小太大,因为图像太多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个通用应用。对于一个屏幕,我使用控件在网格中显示6个图像(png格式)。此屏幕同时支持纵向和横向。

I'm creating an universal app. For one screen, I'm displaying 6 images (png format) in a grid using this control. Also this screen supports both portrait and landscape orientation.

我为所有iDevices创建了一组不同分辨率的图像,并使用正确的命名约定命名它们,如下所示。

I've created a set of images in different resolutions for all the iDevices and named them using the correct naming convention as follows.


  • name~iphone.png

  • name@2x~iphone.png

  • name~ipad.png

  • name@2x~ipad.png

  • name-568h@2x~iphone.png (iPhone 5)

  • name~iphone.png
  • name@2x~iphone.png
  • name~ipad.png
  • name@2x~ipad.png
  • name-568h@2x~iphone.png (iPhone 5)

我必须创建另一组这些图像,因为我支持两种方向,我不能使用相同的上面的图像,因为在风景中它会拉伸。

And I had to create another set of these images since I support both orientation and I can't use the same images as above because in landscape it would stretch.

现在我只有一个屏幕有近60张图像,应用程序已经重达40MB!不言而喻,这是不可接受的。

Now I have close to 60 images for just for one screen and the app already weighs ~40MB! It goes without saying this is unacceptable.

我的问题是,是否有必要为所有这些尺寸/设备和方向创建单独的图像?我不能只为视网膜显示器创建一个套件,它会缩小到正常显示器吗?如果那是不可能的,有没有办法缩小图像的大小?

My question is, is it necessary to create separate images for all these sizes/devices and orientations? Can't I create a set for just the retina display and will it scale down for normal displays? If that's not possible, is there a way to shrink the sizes of images?

谢谢。

推荐答案

不是必须的,但你应该做或至少与其他因素保持平衡。如果不这样做,主要问题与内存(RAM)问题有关,较大的图像占用大量内存空间,而分辨率较低的设备比视网膜内存的内存少。所以缩小并不是最好的选择。

一个可能的解决方案是采用一个大的图像,也可以为其他图像调整大小。为此,您需要使用Core Graphics或ImageIO重绘图像,此库可能非常有用 NYXImagesKit 。当然需要付出代价:

Is not obbligatory, but you should do or at least balance with other factors. The main issue if you don't is related to memory (RAM) issues, bigger images take a lot of space in memory and devices with lower resolution have less memory than retina ones. So shrinking is not the best option.
A possible solution would be take one "big" image that could be resized also for the others. To do that you need to redraw images using Core Graphics or ImageIO, this library could be useful NYXImagesKit. Of course there a price to pay:


  1. 需要计算时间

  2. 来源大图像应至少打开一次才能进行计算,如果你已经记忆不足则可能是个问题

GUI(不仅仅是)元素有另一种解决方案,使用PDF vect图像。你可以在Matt Gemmel找到一篇有趣的文章 a>

如果你的图片没有使用alpha频道,请使用jpg !!!!

There is another solution for GUI (not only) elements, use a PDF vect image. You can find an interesting article here by Matt Gemmel
If your images are not using alpha channel go with jpg!!!!

这篇关于应用程序大小太大,因为图像太多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆