what iOS maximums are set for height width of HTML5 Canvas? - iphone

I came up with a design where I have a larger canvas nested inside my main one. The main one I will refer to as ctx. I move the larger one around and ctx masks it nicely. I did my dev in chrome and safari and it works nicely.
When I host it and check on my iPad3 I discover some limitations.
Apparently there is a maximum limit set to the height and width for an html5 canvas in iOS !
So I stripped down my code to a basic handful of lines to do testing. A 2000 x 2000 canvas will nest fine and display on an iPad3 but when I go up to 3000 x 3000 it shows blank.
I'm now left with a burning question - what are these maximums and do they differ for older iOS devices?
I did try searches but I can't find the answer so I turn to stackoverflow for help.

I've run into this before as well, I think the problem is the amount of available video memory. It's not a specific width/height that is a problem, it's the width multiplied by the height, and the actual number is probably hardware specific.
Hate to say it, but I think you're just going to have to try it out and see what you can/can't get away with. Design your app around that restriction.
Note that the iPad 3's retina display means this it actually has slightly worse video performance than older generations.

Related

Why a defined 1600px large full page image (header) is scaled on iphone

this site in development look fine in many different browser except on my iPhone4s safari browser. For reason i don't know, the full width image at the top is "scale"
site in question : http://studioteknik.ca/stada/
The question is, why the scaling append, and what to do to get it perfect as in desktop browser.
Other sub question : do you know a library that can help make mobile and destop look the same, i mean for image but for text sizing.
The question is not localized or precise, it's a development question for crosse browser compatibility. Thanks in advance.
And BTW, i test it in iPhone emulator online, witch they all pretty much sucks, and don't really show reality, but they show all the site correctly! so i am more mystify that anything else (as opposed to being help)
To prove my point, here is a screen capture of my iphone render : http://studioteknik.ca/stackoverflow_question/stada.jpg
Goggling for the right thing (resized sprite on safari iphone) lead me to the right answer. Here is the solution and some other site i have found interesting, helpful information.
from : http://www.teknocat.org/blog/web-development/show/6/mobile-safari-background-image-scaling-quirk
It turns out the reason for this is a resource limit on the iPhone - the amount of memory an image can use once downloaded and opened. This same limit applies to mobile Safari on the iPod and iPad. Note that this limit is nothing to do with the file size. The maximum limit for images is 1024x1024x3 (3,145,728). If the width and height dimensions of your image multiplied together exceed this value, the image will be down sized. The result can vary depending on the viewport size (whether you're on an iPhone or an iPad).
and more resources :
http://www.thecssninja.com/css/high-res-sprites
http://coding.smashingmagazine.com/2012/08/13/coding-qa-with-chris-coyier-responsive-sprites-responsive-font-sizing-media-query-efficiency-more/
http://www.studiopress.com/design/css-background-size-graphics.htm
http://perishablepress.com/target-iphone-and-ipad-with-css3-media-queries/
http://css-tricks.com/snippets/css/media-queries-for-standard-devices/

How to make Adobe AIR application for iOS supporting both new and old screen size

I've been a Flash animator for a few years and recently tried my hand at developing a simple iOS application using Flash CS6 and AS3.
When I began development I was creating for the iPhone 4S' screen size, however now with the release of the iPhone 5 the new screen size obviously doesn't fill the screen, resulting in the black-bar letterboxing at the top and bottom of the screen.
I have three questions to ask:
Is it possible to release two different versions of the app onto the App Store for separate devices or does it have to be universal? (I believe the answer is the latter but I can't find a definitive answer)
Is it possible to have a stage size that matches the iPhone 5's larger display but cut off the bottom (for example) for the previous iPhone sizes, in effect just adding some information to the bottom of the screen exclusively for iPhone 5 users?
If (2) is not possible, is there coding examples available change positions of items on the screen? For example, I have a title and taskbar as well as a background, could I code it to stretch to the size of the device screen rather than the stage? And would I need to alter the stage size or is there code available to do that for me?
I'm quite new to the programming aspect of AS3 and I'm sorry if there are answers that you feel that I should know, but I'm really thankful for your time to read and answer and I thank you in advance for your replies!
Ben Kahan
While all of your options are possible, you'll want to make sure your program dynamically lays itself out and resizes visual assets depending on screen size, pixel density and orientation.
More here:
One Application, Five Screens (Including the iPad)
and
Writing Multiscreen AIR Apps
You should look into doing number 3! 1 will be a hell to maintain, 2 will piss off users with smaller screen. If you design your application a bit more flexible, that would also mean you have an app that works on android ;)
I don't have any particular code for handling different screen sizes, but I remember reading about it back when Adobe introduced FP for mobile. This article gives a lot of good advice for delveloping for mobile (even though it is a bit old) -- maybe you can find something that is more up to date though google :)

Cocos2d/Cocos2d-x Retina Issues

I have a multiplatform iOS/Android game that I programmed in Cocos2d-x. I have only one set of images to use (I'm only after high res devices) that get scaled according to the device's resolution. For example all images are for the iPad but if you are using a Galaxy S then the image locations and scaling are affected by GalaxyS_screenWidth/iPadscreenWidth.
This works fine for all Android devices and on iPad, iPad2 and old iPhones, but with Retina iPhone there is a problem. On the iPhone 4 all my images look extremely pixelated, a result from the images being scaled to iPhone non-retina resolution then scaled back up to fill the screen.
I tried enabling Retina Mode and the images are half of their intended size (maybe due to the usage of get winsize() which uses points) and scaling manually causes other sorts of problems. I tried playing with a lot of options and attributes but to no avail, so what should I do now?
EDIT:
This is not only a graphics issue, as text gets automatically scaled down then up and appears pixelated.
EDIT 2:
Fonts are bitmaps so my bad. But I don't want to use retina as all images are already retina by default. All of my images are set up for the iPad so for iPhone 4 I just scale them down a bit. This works with Android phones.
For example I have an image, depending on screen resolution obtained through getwinsize():
If current resolution width is 1024 then image stays the same.
If current resolution width is 900 then image gets scaled by 900/1024, no problem.
If device is iPhone 4 resolution width is 480, so image gets scaled by 480/1024, then cocos2d-x automatically scales the resulting image by 2 thus the pixelation. I tried using getwinsizeinpixels, I tried multiplying the screen size, I tried many things but nothing worked out of the box unless I am to redo many of my code.
So the question is, how can I just let the damn engine treat the iPhone 4 as an Android phone with resolution of 960x640?
If you want Retina resolution images to look like Retina resolution images, then those images need to be in Retina resolution (960x480).
If you first scale down the image to 480x320 and then upscale it on the device, it will of course look blurred. You can't magically make the Retina pixels appear from a lower resolution image by scaling it up.
SI couldn't get to the bottom of it so I employed a hack. I enabled Retina Display then I scaled everything x2 through code except for the text. Sounds stupid, but it worked, and pixelation is gone. Thanks everyone who spent time trying to help me.
I tried enabling Retina Mode and the images are half of their intended size
when you enable retina support, cocos2d gets images by appending #"-hd" to their provided filenames. Such images are meant to be double the "visual" size (in iOS terms, pixels vs. points), so that they can be sort of scaled down to make full use of device resolution.
If you have a look at the CCDirectorIOS class, you will find there a couple of methods dealing with this, especially those dealing with the scalingFactor. I don't know what kind of changes you should do to make it work, but if you step into those methods and look at the value of various objects, you might find a way to modify cocos2D default behavior for your specific case.
If this seems to complicated, one thing you could try is changing the CC_RETINA_DISPLAY_FILENAME_SUFFIX so that cocos2d will not look for specially-named files for the retina iPhone, but just use the normal ones.
For example all images are for the iPad but if you are using a Galaxy S then the image locations and scaling are affected by GalaxyS_screenWidth/iPadscreenWidth.
Another thing you might try is not using winSize, but winSizeInPixels, so that when you scale down, you down do it down to the point resolution, but just to the pixel resolution (which is double the point resolution).
Hope this helps.

CSS sprites messed up on iphone

I've noticed css sprites seem to show 1 more pixel than they should when viewing them on the iphone. My site works perfectly fine on all major desktop browsers on mac and PC. But when I view it on the iphone you can see 1 pixel of the adjacent sprite image.
Anyone encounter this before? Any suggestions on how to cleanly fix this? I know I could just modify all my sprites to have more separation in between them, but is there an easier way?
UPDATE: Tested zooming with safari, and noticed the exact same problem occurs at certain zoom levels on desktop safari
Better late than never:
It's not a bug or a software flaw, it's simple mathematics: the (older) iPhone displays websites at 980px width on a screen that is 320px wide (in portrait mode).
So it's a rounding issue: let's say an element is 50px wide. It is displayed at roughly a third of its size, and that is causing the problem: the iPhone will display it at either 16px or 17px width. Even if it was exactly one third, the problem would remain, and the same applies to various zoom levels, of course.
If it's 16px, you're fine - you have probably noticed that the issue doesn't occur on all your elements. If it's 17px, it means that the element is displayed slightly larger than intended, and the adjacent sprite will show.
I checked apple.om on an iPhone 3G, and even their navigation bar shows some odd little artifacts at the bottom - they're just barely noticeable.
So in theory, it should be enough to add 1px around each sprite. Having to change all these elements is a bummer, but it seems to be the best solution. The problem isn't likely to go away either - the iPhone 4 obviously still scales things down, at least in portrait mode. Not to mention all the other smartphones out there with far inferior screens.
Add another 1px of space between the icons.
.:edit:.
Just noticed that this was one of your proposed solutions. Check the elements with the sprite and make sure that they are the right size. (Double check the rendered border-box model in Firebug).
It could have something to do with how the mobile phone renders items.

How will I have to update how I program for iPhones now with iOS4?

For example, preparing a launch screen of 320 x 480 would have to be changed....
How is that going to work for us? Are programmers always going to have to be submitting a high-res that will be scaled down for old devices such as the iphone 3g?
The size of the screen is basically 4 times on a pixel by pixel basis. So each pixel of your image for example gets boosted to 4.
What this means for you? You don't have to change your App, your app will scale to the hi res screen for you, same with your UI and images within your UI. Of course if you want to take advantage of the better screen quality you will have to submit hi res images.
I haven't looked at going the other way but I believe it would be a similar case.
One exception to this is text. It automatically scales to the higher res for you for free. So text will look super sharp. One problem with this is if your loading image has text based on the original load screen that wouldn't look the same as when the high res text loads.
Strictly speaking, anyone who's seen the documentation on how they're handling this is still under non-disclosure until Monday, when the new iOS ships.
Suffice to say, it's clever. You'll be able to put both high and low-rez versions of ALL your images into your app, and then load them into your app in a way that's totally transparent from the code side. The device will make its own call about which version of the image is appropriate for the kind of screen it's got.
Now that the WWDC 2010 videos are available for free to any registered iPhone developer (or ADC member), I recommend watching Session 134: Optimize your iPhone App for the Retina Display for a full description of what you need to do to support the iPhone 4's new display.