Android NinePatch images seem to be standard .png files with extra information. Is there a spec for the format anywhere, as I'd like to be able to implement this on other platforms?
This is the most straightforward link I've found on the subject.
Just take a look at a 9 patch image in an image viewer. It's simply just a 1px border with black pixels flanking the stretchable areas and transparent marking the static parts.
If you zoom into this image you can see the black border marking the stretchable area:
example http://web6.twitpic.com/img/91916457-a53b6866db73378bda07c039151c69aa.4bd6119a-full.png
I would strongly suggest that you not implement the 9patch system on other platforms, for several reasons.
I have been using Android's developer tools for a year and have made extensive use of 9patch files.
They are a nightmare. PNG is not a data format, it is an image format. Mixing the two in the .9.png file is asking for trouble.
9patch files are a poor idea because they combine image and data formats into a single file that is neither fully manageable by a designer nor a developer.
Nine patch files: you will regret your involvement at some point during maintenance, support and updates phase.
Perhaps if at some future date support for 9patch files is added to a number of quality tools (for example, PS CS4 doesn't understand 9patch files as a specific format, nor does it honor the rules of valid nine patch formats.)
The existing tools for nine patch files are awful -- essentially unusable in the opinion of most designers who I have hired.
This Link is very useful for nine patch image in android.
It is very useful example in android. Only use .9 patch PNG file.
http://blogingtutorials.blogspot.com/2010/12/android-nine-patch-example.html
Modern browsers support CSS 9-path based backgrounds:
http://www.css3.info/preview/border-image/
I found this link to be very useful: link to blog post. It uses some examples for the different borders defined when a 9 patch is created. It shows how the extra information is used in scaling the images' dimensions (x,y).
There is even a nice comment by a Richard L. at the end which says how you can add regions to be protected from scaling the image by including breaks in the borders; eg. not scaling sections in the image.
Took me a while to understand that the Extension of the 9 patch file should be xxxx.9
and not xxx.9.png
Related
We've already built projects like DocuSign in both iOS and Android, we've quite extensive use of documents which is loaded in form of PNGs, where users can quickly move to their selected page (e.g 1 -> 25), so we worked on closely to make it stable and fast but we've requirement to not gets pixelated while zooming (where PNG lack and gets pixelated), so I done R&D on vector base supported in iOS and found that PDF will not fit for our requirement but SVG may fit. But As SVGs aren't natively supported in iOS so
Is it the right decision to use any third party for SVG support in iOS
like https://github.com/SVGKit/SVGKit in large scale projects?
Will memory management will effect I read many links where it
mentioned it's not recommended like
https://www.quora.com/Should-you-use-SVG-files-for-images-in-an-iOS-app
?
Does anybody go through this kind of problem? looking for suggestions and solutions.
NOTE: These images are coming from cloud(our server, google drive, dropbox and One drive)
You can use Vector xml
Right click on rec>drawable folder
select Vector Asset
then select Local file(SVG)
Pick path of svg file
and import this will convert your SVG to the vector xml file, this vector drawable you can use in place of PNG files
I am using the Android 9-patch tool to generate my 9-patch images. I have to support a number of different resolutions and button states. This means that for a single 9-patch button I need to generate 16 separate assets. Currently I am generating each of these separately using the Android 9-patch tool interface which is taking a lot of my time. If I was able to specify the 9-patch dot for a range of buttons which have the same properties this would save me a lot of time. Is there the equivalent of a command line tool or other approach which would help.
Thanks
Here is a nifty looking tool I just found. I cannot verify its accuracy or stability, but it claims to do what you want.
You can try to use the Android Asset Studio at http://android-ui-utils.googlecode.com/hg/asset-studio/dist/nine-patches.html.
Well, there's is no tool as you like afair, but you could easily craft small script (PHP, Perl whatever) that would combine two images (main image + 9-patch dots) together. Or you can save dots separately and then load it into GIMP or Photoshop as layers and export as single final 9patch PNG.
How do I programatically extract tiles from a tileset such as this one: http://opengameart.org/sites/default/files/grassland_tiles.png
I want to use these tiles in my game. I see that some tiles here are of different sizes (or maybe all tiles are a multiple of some fixed size). For example, if I want to use one of the tree tiles in my program, how can I figure out what offset into the tileset image I must use, and how big of a sub-image i must extract? I don't see any metadata associated with any of these tilesets that I can use.
Also, is there an Android API I can use to extract a part of an image from a bigger image?
Thanks!
Answering my own question. I missed the following line on the page I got this png from:
To use the tile set in Tiled v0.8, get the necessary files from the
Flare git repo.
The git repro in question is here, which seems to have several metadata files which describe the tileset.
Thanks to everyone who commented.
I have a problem with an image for an android game. The problem is not a problem with the code because the code that I use I took from a book (Beginning Android 4 Games Developer).
The problem is this: I know the format that I have to use in android: png, but I don't know the settings for this format that I have to use (like RGB565...). Because if I use simply png, when I run the game the images are not good. So I need someone to explain to which settings I need to use for images for android games.
P.S The software that I used is photoshop. If there is better software for this purpose tell me.
I think there is a strong misconception in your understanding of Android and how it implements graphics. You are not constrained to .png for nearly any of your development. The .png and .9.png are only enforced strictly for managing drawable constants.
Android uses Java and has the capability to utilize nearly any graphical format. In particular native support for .bmp, .png, and .jpg are present for every device and Android OS version. You may even create your graphics in realtime byte by byte.
As for a good image editor, there are a number out there. I often use a combination of GIMP and Photoshop, myself.
Hope this helps,
FuzzicalLogic
A long time ago I came across a video from one of the Android developers giving an introductory lecture about Android. At one point during the lecture he mentions that Android is optimized for specifically formatted PNGs. I can't find the video or any reference to the formatting. Does anyone know?
Are you referring to android .9 PNG's? if so here is a link
Android PNG
.9 PNG for Themes youtube video
hope that helps
I didn't find the video, but I did find this.
http://developer.android.com/guide/topics/graphics/2d-graphics.html#drawables-from-images
Taken from the first line:
Supported file types are PNG (preferred), JPG (acceptable) and GIF (discouraged).
Furthermore, if you look a little bit down, it goes into detail about NinePatchDrawable graphics, which are expandable PNG files and would explain why Android prefers PNG files to any other kind.
You could take a look at these slides, which I felt were very helpful and a must-see for many intermediate Android developers. Although he doesn't talk exactly about what you are asking, it may still be helpful.
I've found the video and the formatting I was referring to in the OP:
The format is 565 formatted PNGs. The reference is at 0:04:17 here: http://www.youtube.com/watch?v=7zKy9iInXkY
It should be noted that this video is quite old. I cannot find any references to the 565 formatting in the current Android documentation. Formatting PNGs in 565 may be unnecessary now.
You can optimize png file size using OptiPng tool (find using search). And it appears that RGB565 mode is drawn faster than ARGB8888 when you use Canvas. See here: http://www.rbgrn.net/content/286-how-to-test-android-performance-using-fps. And png could be transparent :) That's all I know.