开发者

iPhone image resource - 1024 maximum, 2048 pixels @2x?

开发者 https://www.devze.com 2023-01-19 22:36 出处:网络
The restriction of 1024x1024 as the largest image for an iPhone is a problem with iPhone 4. However if an @2x image is used with maximum dimensions of 2048x2048 everything looks equally good on the 4

The restriction of 1024x1024 as the largest image for an iPhone is a problem with iPhone 4. However if an @2x image is used with maximum dimensions of 2048x2048 everything looks equally good on the 4 as it does on a 3 - tried and tested i开发者_运维技巧n simulator and device. Question is, does the image dimension restriction relate to the UIImage or the resource that it contains? I can't imagine resources of more than 1024 pixels are discouraged with the 960 pixel height of the screen.

The right answer is really to use tiles so that things look even better, but the deadline for for this deliverable is too close - it's a future thing.


From UIImage class reference:

You should avoid creating UIImage objects that are greater than 1024 x 1024 in size. Besides the large amount of memory such an image would consume, you may run into problems when using the image as a texture in OpenGL ES or when drawing the image to a view or layer. This size restriction does not apply if you are performing code-based manipulations, such as resizing an image larger than 1024 x 1024 pixels by drawing it to a bitmap-backed graphics context. In fact, you may need to resize an image in this manner (or break it into several smaller images) in order to draw it to one of your views.

That is, views are rendered and composited with the iPhone's GPU. If your view, for example, overrides drawRect and tries to render a very big UIImage you might run into problems. Newer generation iDevices, such as iPad and iPhone 4 support bigger textures than 1024x1024 (2048x2048 I think).


I didn't realise there was a restriction, I'm using an image 15198 × 252 as the scrolling landscape in Scramble... works really well, though I must say I did have reservations before I tried it out!

0

精彩评论

暂无评论...
验证码 换一张
取 消