Android: changing density for game performance? - android

I currently have a note 4 which has a high resolution screen (2560x1440) that, when playing in the native resolution, doesn't perform well somtimes.
I have found apps on the play store that will allow resolution changes but all require root (at&t version is currently unrootable).
I can however change the density of the screen without root.
I'm curious if I would receive the same performance boost changing density as I would changing resolution?

Highly unlikely.
The resolution defines number of pixels displayed on the screen. When you change the resolution, the system changes the size of all image buffers used for rendering. It means that there is different numer of pixels to shade and draw.
On the other hand there's the density, which define, how much pixels you can fit on one inch of the physical screen. The density changes an internal matrix used for scaling images. The operation is always same. In apps with native Android UI you may gain a small boost, because by changing the density value you can change the density type of your screen (medium, high, xhigh, etc.). This will change the drawable folder used by the app to the (potentially) smaller one, which will result in faster image loading and messed up UI.
This trick won't work for the games, because in most cases games don't care about the drawable folders.

Related

Blurry web graphics on smart phone - double image size or resolution?

Various web graphics I've created are blurred on high resolution smart phone screens, unlike desktops screens.
Do I need to:
double the image size and programmatically resize it to half
increase the resolution (e.g. 72 to 300).
My understanding is that the latter only affects print rather than digital screens.
Are others experiencing this issue and if so, what it is the recommended work-around?
Your assumptions are correct. You need to double the image size, maybe even a little more if you wanted to get picky as some screen resolutions have 3x or more pixel density than a desktop monitor. Double works pretty well though so I would start there.
Resolution, as in DPI, won't do anything for web graphics on screens besides make the image resource's filesize larger than it needs to be. You could have a resolution of 5 DPI and they would look the same as 300 DPI on a screen. The main issue with lowering DPI for web graphics is when a user wants to print your page, then any images with really low DPI would be very pixelated.
Depending on the graphics you've created you have some options besides your standard image formats. You can use SVG or create your own icon font. Both are vector images so they will look sharp on any device that supports them. Icon fonts are widely supported and SVG is decent but might need a small shim depending on what you need to do.
Double image size.
You should even render image (simple or doubled), depending on the device/viewport resolution.
increasing resolution is quite a complicated matter. Print/digital/dpi/ppi; it could work on a bunch of devices but not all.

app crashes when opening multiple image

I am making an app for story books, i have my curlview animation for this app.
My problem is that i dont know what size of image and what resolution should i use for 3.5 inches to 5.0 inches screen.
I always reading on supporting multiple screen size but the problem is that i cannot get that.
All i want is the exact image size in pixel and what is the resolution should i use.
i always use 72 as resolution but i dont know what is the dimension should i use for 3.5 to 5.0 inches screen size.
did anyone knows what should i use? i dont want to read supporting multiple screen size because i already read it and i did not get it.
Thank you to someone who can give me the size i should use that will not get crash in my app.
Thanks again!
As it said in the Android style guide icon size scale for different screens should follow the 2:3:4:6 scaling ratio. Maybe you can use this ratio for other, not only icon, images too.
As you write you read the documentation, I assume you already read the Android Best Practices Chapter about Density Independence. If I got your question right, you're looking for the following part of it:
The system scales dp units as appropriate for the current screen density.
The system scales drawable resources to the appropriate size, based on the current screen density, if necessary
[...]
By default, Android scales your bitmap drawables (.png, .jpg, and .gif files) [...] so that they render at the appropriate physical size on each device.
So you basically need to provide an screen-size independent layout, and Android takes care of the rest. However it is encouraged to deliver multiple images for a better scaling quality.
If you can only afford a single size for the images, I'd decide on a target audience (e.g. how likely are Tablet users, what is the average device's screen size in my audience -> how many pixels will be available in the area you want to display the image) and then calculate the resolution of the images based on that. If a user needs a smaller or larger version, Android will scale the image up or down, given your layout is correct.
From what you write, it seems to me like you're targeting normal screen sizes, so you can have something between 470dp x 320dp and 640dp x 480dp. To get regular pixels, you must think about the screen density of your users, refer to a Question about dp/px conversion for details.

Android game location on screen size

Right now my game is using direct x and y values. I realized that my the S3 was scaling my images double size along with some other size inconsistencies between devices. I read around and learned a bit about android dpi and scaling and stuff.
I'm wondering whats the correct way to do locations and stuff so that it takes into account different screen sizes.
I'm thinking it can be done by setting a target dimension and then scaling all positional values according to the ratio of the target dimension to the actual screen size.
I also read somewhere that you can draw onto a buffer and display that buffer stretched to the screensize, however for this method would android's auto resizing affect the drawn bitmaps?
Thanks
The idea is to use aspect ratio, android auto resizing to your benefit. Every android screen has its own aspect ratio, your game should use the aspect ratio and fill blackborder where ever there is a need to fill space on the screen. So use appropriate root layout fitting attributes.
Android resizes drawables automatically that dont fit. So if you keep only 1 set of drawables, the resizing work for Android increases and it uses Bitmap's internally to do the resize. More the bitmaps more the memory utilization, more the cleanup, more the GC and slower your game. So the best practice here is to create different dpi different image sets to use.
To start with I suggest that you purchase 3 phones, samsung y (small screen), samsung s2 (good screen) and a tab 7 or 10 inch. Copy your original drawables to all the folders, just to get a feel of the game and to eliminate all memory issues. Once your game works nicely, smoothly without any memory issues on all the phone sizes, just walk into a graphic designers office and show him how bad your game looks on some phones. He will create graphics that will work for that dpi.
Its a game of intelligent drawable resolution, sizing and A WHOLE LOAD OF TESTING :).
Hope this has helped.
Edit : Read my answer in memory issues

One high density folder instead of three folders

This is the typical area of supporting multiple screen sizes for android. Basically, in my cards game it was really too much to provide the setof 52 cards duplicated for the 3 folders (ld, md, hd). The reasion is the increased app size by quite a bit.
So I was wondering, if I only provide high density folder then would the device scale down the images to appropriate densities. I mean if all what I was doing before was resizing the images down then the scaling down by the device would be same. right?
If I do that (porviding only high density folder), will the image end up taking the same physical size on low density screen (I am using high density as it is generally to scal down than up).
Thank you
PS: Please don't give me the android website. I want your answer/experience
The answer is, it will scale them down for you, but the resulting images will be lower in quality than those provided at the correct density, depending on how it is downscaled and by what percentage. It may or may not be that noticeable depending on the type of graphics, but fine lines and single-pixel details will be most noticeably different.
I have a game card too and i have put all my high-res cards in res.raw.
It should be the same in drawable-nodpi.
On all the device tested, the cards render very good. The phone just scale the cards up or down depending on the screen size.

android developers - what do you need from the designer?

i am NOT an android developer and im trying to understand what they need in terms of graphical resources to make an app that functions across many android devices.
i have (tried to) read this page http://developer.android.com/guide/practices/screens_support.html , but find it somewhat bewildering. they talk as if screen density is the important thing "Supply alternative bitmap drawables for different screen densities" but then, if you dont know the size of the screen, you cant really think in terms of layout. is the idea to make buttons and logos that are the same size on all screens with the same density, such that on a large screen there is just a bunch of space, and on the small screen its all packed in tight? i dont understand how just thinking in pixel density gets me any closer to knowing what to provide.
are you supposed to create resources for every screen size AND pixel density? say it aint so.
anyway can somebody tell me... if you were developing an app what do you need for graphics? is it possible to provide graphics that are large and just let them scale down? is it inevitable that the devloper will have to mess with the graphics himself anyway? or can he be provided with sets of png files of certain sizes that will be ready to use?
thanks!
Here's what we do at my work place. Suppose we get a desing for the app. We make our designer create 3 psds versions for the same desing. the 3 psd's are for the 3 ranges of desnity. The size used for the psd are
240*320 (Low Density)
320*480 (Medium Density)
480*800 (High Density)
Most of the time when I write layouts, I use wrap_content which means a view must take the size of the content it wraps. Which works most of the time as I have a density specific version of the design so the image i use as background should be suitable. The thing to note is that, in android you can can put the 3 sizes of the same image in different folders such as drawable/ldpi, drawable/hdpi.
Eg: you have a bg.png and have a version for large phones and a version for small phones. You put the big bg.png into hdpi folder and the small png in the ldpi folder. Android will automatically select the appropriate image based on the phone density. But you need to make sure the file name is the same.
There are cases where you need to resize you background images without makeing the image looking too scaled. For this android uses the draw9patch tool. With this tool you can specify areas which can scale and areas that shouldn't scale.
9 Patch png's are your friend. Read up on them here:
http://developer.android.com/guide/topics/resources/drawable-resource.html#NinePatch
and here:
http://developer.android.com/guide/developing/tools/draw9patch.html
Those are your best bet for any kind of graphic that will stretch nicely (i.e. not gradients, they will come out slightly pixelated on some screens probably) The power of these types of images is that you can tell the system which pixels to repeat if it needs to stretch the graphic. This means that stretching can be done without loss of image quality (again depending on your image and how you choose to make the nine patch. The "show bad patches" button in the draw9patch program will show you potential problems. Hint: keep your repeatable pixels down to 1 on left and 1 on top and you'll have no problems with bad patches) Any graphics that can be made in to 9 patches will only need 1 size since the system can effectively make it whatever size it needs.
are you supposed to create resources for every screen size AND pixel density?
You may if you like. This would ensure that the application will look great across all devices. I understand that this is not feasible for all projects though. In general if you make separate resources for the different densities you'll get something that looks acceptable on most of the devices out there. All of the devices are classified as ldpi, mdpi, or hdpi (there may be an "extra high" level now too, I am not certain off the top of my head) So if you supply graphics for those 3 densities then the system will know where the device falls under and will pull the correct graphics.
is it possible to provide graphics that are large and just let them scale down?
Yes the system will scale down your graphics if needbe. But be aware there are consequences with this approach. First every time the system hast to scale a graphic up or down it is going to taking up CPU and memory to do so. This may not be an issue if you have relatively few things to scale, but if you have many it could cause noticeable lag time during on the lower power phones. Second, To my knowledge all of the graphics in android are raster, which means if you are letting the system scale something up or down image quality is going to decrease some. Again depending on the specific images this may be more or less noticeable on the actually device at runtime.
My best advice is supply them with resources of a few different sizes and run the app on as many different devices as you can. Once you see how your different resources look on the devices of different sizes you'll have a much better feel for which ones you need to supply to get the UI looking as consistent as possible across the largest swath of screen sizes and densities.

Categories

Resources