Today I'm going to show you how to work with/convert the .pkm and .atc image files that are included in system apks on recent devices. It's been about a month since I've looked into these formats, so if anybody has since come up with any better/alternative methods, please share them here.
.pkm files are actually a type of ETC1_RGB8 textures. The reason manufacturers are starting to use them, is because they are fully supported by Android, and with the OpenGL ES platform that Android runs, they offer significant overhead savings vs conventional image formats. A lot of people (devs included) probably haven't realized it, but there is actually a tool that comes bundled with the Android SDK for creating .pkm textures. It's called etc1tool, and is a command line utility. Etc1tool is capable itself of converting .pkm files to .png, but unfortunately all the ones I've come across in pre-existing apks are not able to be converted this way. That would be too easy, right? So, here's what we do instead:
-First, you're going to need to download and install Mali GPU Texture Compression Tool from HERE.
-Once you've got it all set up, open it up, go to File > Open, and open up a .pkm file (or several, as it can do batch processing).
-Now, click on the .pkm file you just opened, in the left-hand pane to select it. You should see the image.
-Next, click on the yellow icon towards the upper right of the screen.
-In the window that pops up, copy the settings I have here. You can change the directory (it's only going to store a temp file anyway), but everything else must match.
-Click OK, let it do its' thing, and you should see a screen similar to this:
-Now, you're going to click on your image(s) in the left-hand pane to select them again, then click on the blue save icon towards the upper right.
-Save them to whatever directory, and with whatever extension you'd like (most likely .png). Now, the standard ETC1 format doesn't handle alpha values, and the existing .pkms seem to have been encoded using some proprietary method that preserves the alpha channel. When you save your image from Mali, it will not save the alpha values, despite the preview having them. As a result, your .png will have a black background, similar to this:
From here, though, you at least have a standard .png image, which you can then open with Photoshop or Gimp and easily remove the black background.
-If for some reason you'd like to create your own .pkm file(s) from existing images, navigate in command prompt to the your Android SDK > Tools directory, then use the following:
etc1tool pathtoinputfile.png --encode -o pathtooutputfile.pkm
.atc files aren't going to be as common as .pkm, as they are a proprietary format and can only be used on device with a Qualcomm Adreno chipset. Just like .pkm files, they offer significant gains in overhead performance compared to standard image formats, but they are a pain when you're trying to theme an app that's full of them. Let's begin...
-Start off by downloading the ASTC Evaluation Codec found HERE. This one is going to be a zip, rather than an installable program, so download it and extract it wherever you wish. Once extracted, find the location of 'astcenc' (the folder names are odd, and differ depending on your OS).
-Once you've located it, open up command prompt, and navigate to that folder.
-Like etc1tool, the ASTC Codec is capable of converting directly to .png, but also like the .pkm files, it doesn't work in this case. You can try, but the result will be unusable, so don't waste your time. Instead, we're going to convert to .tga.
-So, in command prompt, use the following to decode the .atc to a more usable .tga:
astcenc -d pathtoinputfile.atc pathtooutputfile.tga
-Unlike .pkm files and Mali, this will preserve any existing transparency, but there's a catch (there's always a catch). The resulting .tga file will be upside down.
-Fortunately, this is nothing more than a minor inconvenience lol. So, once you have your .tga file, open it up in Photoshop or Gimp, flip it, and save as .png, and you should be all set.
-If for some reason you wanted to create a new .atc file, the codec can be used for that as well. I forget the command, and documentation is very hard to find, but if you use the following, you should be able to go from there: