[HTC EVO 3D] dkdude36:
how to easily edit .9.png's

hello theme guide thread. been a while (never) since i've posted a tut here. about time i do. so here's my guide on editing .9.png's. this is what i do to edit 9 pngs for mac. it might be the same for pc, it might not, idk.

what you'll need:

either eclipse or my png compiler/decompiler apk (i put at the bottom). eclipse is a lot less messy, but both work fine.

apktool

an image editing software

the android sdk including draw9patch

zipping/unzipping software (default mac works, but i reccomend betterzip)

an image to edit

common sense (which i struggle with all the time)

patience

skip steps 1a/1b if your image is already in an apk

step 1a: the eclipse method

after setting up eclipse with adt plugin, go to create new android project. select create android project as the wizard. project name is up to u. select the api that you're dev'ing for (probs api level 10). give your apk a package name and activity name. none of this matters btw. once you have the apk, place any 9png's you want to edit into the /res/drawable-hdpi folder of the app. right click on the project, go to the bottom and select android tools. select export unsigned android package. you should now have an apk. go to step 2.

step 1b: the messy method for you too stubborn to install eclipse

download my base apk that i have linked near the bottom. unzip it by either renaming to .zip and double clicking or dragging into betterzip. place any 9png's you want to edit in /res/drawable-hdpi. zip the apk back up. rename to apk again. go to step 2. this is not confirmed btw but common sense says it'll work and i'm trying to help you guys out who cant install eclipse for some reason.

step 2: decompiling

after installing apktool, run apktool d /yourapp.apk /whateverdestination. navigate to the folder you decompiled it to. look in /res/drawable-hdpi. move all the (now decompiled) 9.png's to another folder, and delete the apk, as you'll just replace it later. you'll notice there's an ic_launcher.png in there. ignore that.

step 3: editing

open the 9pngs with your image editing software of choice. you'll notice the images all have a 1 pixel border that has either black pixels or clear pixels. MAKE SURE NOT TO TOUCH THIS. i sometimes like to make a marquee selection around the whole image except the 1 pixel border to make sure nothing spills over. SERIOUSLY, DONT EVEN MESS WITH HUE OR ANYTHING ON IT.

step 4: edit the 9patch

type draw9patch into terminal if you have the adb tools folder in your path. or just click the draw9patch executible file in your sdk folder. drag the 9pngs (one by one) into the app. make any patch edits you want here. most will be fine, so just open them up and save them. some you'll want to edit. on the bottom and right sides, anything that the black pixels intersect over is a place where overlays can be placed. on the top and left, anything that the black pixels intersect over will be multiplied until the 9png fills the space provided. usually the multiplied pixels only need to be a single pixel. sometimes you need to choose carefully. either way, open and save everything.

step 5a: recompiling with eclipse

time to open up eclipse again. you can use the same project if you'd like. just delete anything you already put in /res/drawable-hdpi. now place all your 9pngs back into the drawable-hdpi folder. select the export unsigned android package again.

step 5b: recompiling the hard way with apktool

this one is sorta a shot in the dark, so dont blame me if it fails. place the images back into /res/drawable-hdpi on my base apk thingy folder. now go into terminal and type apktool b /whereveryourfolderis /whateveryouwant.apk

step 6: get your images

rename the resulting apk to a .zip extension or open in betterzip. extract it. go to /res/drawable-hdpi/ and take out all the .9.pngs. you'll notice none have the 1 pixel border anymore. it's all now saved in metadata somewhere somehow inside the png. you can delete the apk and the folder.

put the 9png's back where they came from in their respective apps.

linky to my base apk (as a decompiled folder) http://cl.ly/0r0j2v0M0b0e2i2b322s

enjoy