移动safari中的图像大小限制? [英] Image size limitations in mobile safari?

查看:255
本文介绍了移动safari中的图像大小限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PhoneGap的iOS应用程式。我碰到一个恼人的问题,其中一些我的图像没有加载。认为这是一个缓存问题,我玩的图像交换。

I'm working on an iOS app using PhoneGap. I ran into an annoying problem where some of my images weren't loading. Thinking it was a cache issue I played around swapping images.

我终于发现问题与我的图像的高度有关。经过一大堆试验和错误,我发现高于7864px的图像将无法加载在iPad模拟器或iPad本身。它会在Safari中加载罚款。它不是一个文件大小限制,因为这些只有45k的大小,我加载的图像大小在其他地方700k,没有问题。

I finally discovered that the issue had to do with the height of my image. After a whole bunch of trial and error I discovered that an image taller than 7864px will not load in the iPad simulator or the iPad itself. It will load fine in Safari. It's not a file size limitation as these are only 45k in size and I'm loading images that are 700k in size elsewhere without a problem.

有没有人遇到这个?我在移动Safari中找不到任何图片尺寸的文档限制。如果有限制,知道他们会很方便。

Has anyone run into this? I can't find any documented restrictions on image dimensions within mobile Safari. If there are restrictions, knowing them would be handy.

推荐答案

对于本机应用程式,Apple表示图片大于2048x2048 1024x1024要避免和应该分解成更小的。这里的问题不是磁盘上的文件大小,而是内存中的大小:图像必须解码并变成一个平面表示。

For native apps, Apple says images larger than 2048x2048 1024x1024 are to be avoided and should be broken down into smaller ones. The problem here is not the file size on disk, but the size in memory: the image has to be decoded and turned into a "flat" representation.

一些数学:假设一个图像5000×5000像素,具有8位RGB。这表示每个像素占用3个字节:

So let's do some math: assume an image 5000x5000 pixels, with 8-bit RGB. This means each pixel occupies 3 bytes:


5,000 * 5,000 * 3 = 75,000,000(约71.5 MiB)

5,000 * 5,000 * 3 = 75,000,000 (roughly 71.5 MiB)

所以你看到你看起来很小的图像真的填满了内存非常快。 iOS现在不能抛弃部分,如果它是内存压力,它的整个图像或什么。

So you see your seemingly small image really fills up the memory very fast. iOS now cannot throw parts away if it's under memory pressure, it's the whole image or nothing.

你唯一的解决方案是将图像分解为较小的部分。 iOS可以从内存中删除不可见的图像(我怀疑这样一个巨大的图像,所有部分都是可见的所有时间)。

Your only solution is break down the image into smaller parts. iOS can then remove images that aren't visible any more from memory (I doubt with such a huge image that all parts are visible all the time).

这篇关于移动safari中的图像大小限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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