I wonder whether it makes sense to put in my iOS app vector graphics. I wonder whether they could be drawn by system faster or not (from raster - which I can't scale too much - equivalents). Maybe this depends on the complexity of an image ?
Does it makes sense ? To have vector graphics, and don't worry about scaling images between iPad screen and iPhone screen ?
What's the preferred way to embed things like logos, and icons in iOS apps ?
Related
The official documentation Vector Asset Studio states that SVG can be used to reduce APK size. It also states that SVGs take much CPU cycles for drawing.
The initial loading of a vector graphic can cost more CPU cycles than
the corresponding raster image. Afterward, memory use and performance
are similar between the two. We recommend that you limit a vector
image to a maximum of 200 x 200 dp; otherwise, it can take too long to
draw.
Also, it is supported from Lollipop onwards. On backward compatibility, it states that-
Android 4.4 (API level 20) and lower doesn't support vector drawables.
If your minimum API level is set at one of these API levels, you have
two options when using Vector Asset Studio: generate Portable Network
Graphic (PNG) files (the default) or use the Support Library.
For backward-compatibility, Vector Asset Studio generates raster
images of the vector drawable. The vector and raster drawables are
packaged together in the APK.
Raster images look like more efficient than the SVGs. Also, though the size of APK will be reduced, what will be the impact of SVG on memory and app performance as the doc states that it will take time to draw large SVG files.
As an android developer, what should be my approach? Which of above or any other ways will ensure my apps be optimized and deliver good performance.
Edit : A query then, What should be the best approach among the two -
Reduce the apk size by using the SVGs but will increase CPU cycles for drawing
Use raster images
In my own experience Vector Asset Studio is picky about what it accepts in an SVG. If you are not well versed in SVG you are going to have a hard time massaging the SVG markup into something that VAS accepts. From the top of my head I recall it doesn't support defs or filter, but some vector graphics software seems to include it even if it's not strictly necessary. Given flat icons (no gradients or shadows, for example) you can work around this by manually editing the mark-up.
As for performance, it really depends on the amount of icons you will display per screen, and the complexity of these icons. You will have to conduct some stress tests to see if your target devices hold up. Note that this only impacts the initial load, behind the scenes these vector images are rasterized and—as the text you cited mentions: Afterward, memory use and performance are similar between the two.
Your approach should be pragmatic, attempt to draw a couple of your icons on the screen and see how smoothly it goes. This is a subjective question that depends on the constraints of the device and the person who implements it.
My experience using react-native-svg was very good, but animation performance that needs to recompute dynamic SVG suffered from I think they call it 'too many passes over the bridge'. There may be a way to optimise it, and I intend to investigate this on my next RN project. I should qualify this last statement by emphasising that animation only suffers when the SVG needs to be recomputed during the animation (on the JS side). For example have a native ScrollView component with your SVGs inside it, the ScrollView can animate perfectly performantly, but if you want to change the SVGs programatically as a function of scroll position within the React/JS side, you will have the bridge problem, and dropped frames galore.
Here is my boilerplate which sets up a few basic shapes in Android RN:
proto__33__boilerplate
Generally I would say (programmatic) SVGs are great for Android, but I haven't yet found a performant way to use them for animations. Will update if I find that.
I'm doing a mobile game in Unity for Android and iOS, I already have my assets design for a device of 480*800 pixels, but when I launch my game in a biggest screen, the image is horrible.
I tried different technics to scale the camera, the images... without success. In Android there is multiple size of drawables : hdpi, xxdpi... and in iOS the images can't be the same for an iPad and an iPhone, so I did not understand, how I can load multiple images to fit all the screen resolution.
or How to make my assets to do that. Can you explain me please ?
400 pixels is incredibly small for game images these days. We rarely get or use anything less than 4K these days.
One thing: if it is actual "pixel art" (so, "retro" pixel art), you must use the "point" enlarger to keep the "pixel shape" when you enlarge it.
Note that pretty much everyone uses 2DToolkit with Unity for 2D projects. It creates sprite sheets for you. BUT it also has the concept of different sprite sheet sets for different screen sizes, if you are working on a pixel-perfect concept (as much as that has any meaning today).
Unity itself does not contain any "different sprites for different devices" concept, and this is one of the main reasons 2DToolkit remains so popular.
Finally note that: if you make computer games it is
...extremely difficult...
dealing with different screen ratios.
Say you are making a side scroller: what does it "mean" that some players have a wider screen than others? What should you "see" on a wide screen versus a normal screen in, say, GTA?
This can involve a huge amount of conceptual work and programming. This affects everyone who makes games, from the kid on the corner to Nintendo. There is no "simple solution".
I understand that Andengine gives us option to scale our scene to any size screen that the user may have.
My question is if it would be better to develop for a larger resolution, say 1280/800 and scale it down for smaller screens OR to go for smaller resolution, say 800/480 and scale it up on bigger screens?
I did try to test this in a sample game by developing it for 1280/800 and scaling down (by ratioResolutionPolicy) to 800/480, and the results weren't satisfactory, there was stutter every here and there the framerate on the debugger though showed 60+. Is it bad programming on my part or does it have to do with the scaling down of the pixels, should I develop for smaller screen and scale it up?
I guess it depends on what kind of graphics you are using.
Say, for example, you want to create something in a retro-gameboy-pixel style, then it makes more sense to use small images and develop for a small resolution (like 480x320). Pixel graphics can be scaled up without loosing quality, but not down (then the pixels loose form).
But if you want high resolution graphics you are most likely better of developing the whole thing for a big resolution and let the AndEngine scale it down.
In both cases the quality of the pictures also depends on the TextureOption of your TextureAtlases as well.
Anyway, I can imagine that neither scaling down, nor scaling up is more efficient. Scaling is done by openGL and should go quite quickly. The downside of using big resolutions though, is that the device has to hold huge images in it's memory and the of course processing big images always takes more time than processing small images. So maybe the best way is to develop for middle-size devices (e.g. 960x640) ?
I know this isn't much help, unfortunately it is a lot of try and error to get the best results for your specific requirements.
christoph
To achieve good result on all type of android device you have two ways to follow from my perspective.
First, you have to develop and use two graphics to handle all the type of devices. For example one with resolution 1024x600 and other with 480x320. Based on device current resolution you have to load specific one type of graphics.
Second, you choose any single resolution that best suits to you and have great share in the market. Develop and use graphics only for that resolution. For other resolution scale that graphics based on aspect ratio. For this you have to create super class of sprite and change value of x,y,height and with based on aspect ratio calculate.
This was my experience that I share with you. If you have any doubt then feel free to ask it.
I am working on android app. I see lot of apps say they have hd graphics and i can see some difference in their graphics and mine. I searched on google also but cannot get exact answer as to what actually hd graphics means? Is it some kind of format like .png or is it resolution like 400*800. I mean if i want to make hd image of a simple button how can i do that? Can anyone please explain in deatail keeping android apps in mind. Thanks in advance!
Basically you need to check out the definition of HD. That stands for High Definition and it's main idea is that by making resolution big, on bigger screens the quality of an image or a video won't look bad.
About Buttons, in Android or any other OS most of the times vector graphics are used instead of bitmaps. Vector graphics are just some coordinates which make up graphic, so when you zoom in or display a vector graphic on a big screen it won't lose it's quality. Bitmaps are collections of pixels. Check this out to get a basic understanding of dpi and pixels: http://en.wikipedia.org/wiki/Dots_per_inch
In order to use bitmaps efficiently for buttons and that kind of controls I'd suggest taking a look at this: http://developer.android.com/reference/android/graphics/NinePatch.html
I am trying to address a resolution issue when designing HTML for webkit browsers.
So basically the problem is that webkit browsers can have resolution anywhere from 240x320 to 960x640 and I can't have a separate image/icon set for each one but I do want the pages to look the same on all devices (or very close at least).
Scaling the image (working with percentages) works but it's a performance degrade:
http://code.google.com/speed/page-speed/docs/rendering.html#SpecifyImageDimensions
The other option is using vector graphics which is supported in webkit but I am not aware of the performance implications that is going to have on the pages/app.
The other option is to have a few icon sets for some standard well know resolutions and when you get a browser which is outside of these groups you apply some minor scaling on the set which is closest to the users native resolution.
So basically what I am asking is, what would be the best route to achieve this with performance in mind?
Thanks
-Assaf
Vector graphics are always more expensive in terms of runtime performance as complex equations are run to create them. Having said that, I'm not sure if they're redrawn every frame from scratch, or if the result's cached unless it's in a dirty state.
I'd suggest having a few different icon sets for well known resolutions and applying minor scaling if required.
The first answer is not helpful at all. Vector graphics can be just as small as a PNG, and used right can support transparency and various other good features.
The only problem is if your looking for pixel perfect perfection having some of the images scale up might cause problems.
You can also use illustrator to html5 canvas plugin to export directly to html5 canvas.
For our webkit browsers on row icons, we set a property that doesn't allow webkit to scale the icons for desktop browsers. Or for some of the icons we include a small SVG.
They are well supported and work great. Even better would be to use a free font creation tool and paste your vector graphics from illustrator into a font, so that you could use web-font to simply call up ANY size icon, as simple text. We use this technic.