Android etc1tool png image conversion pkm and zipalign Introduction

Time:2023-10-24

About the author: content partner and technologist, building a 10 million daily app from scratch.
Focused on sharing original series of articles in various fields , specializing in java back-end, mobile development, business real estate, artificial intelligence and so on, I hope you have more support.

Android etc1tool png image conversion pkm and zipalign Introduction

I. Introduction

We continue to summarize our learningbasics, warming up to the past.

This article documents the introduction and use of the android etc1 tool.
This article documents the introduction and use of the android zipalign command.

Two, etc1tool

etc1tool is a command line utility that can be used to encode PNG images into the ETC1 Compression Standard Format (PKM) and decode ETC1 compressed images back into PNG.

Simply put, png and pkm image formats are converted to each other.

Files in pkm format in android can be read in the assets directory.

2.1. Usage

etc1tool infile [--help | --encode | --encodeNoHeader | --decode] [--showDifference
diff-file] [-o outfile]
options (as in computer software settings)clarification
infileThe input file to be compressed.
–helpOutputs usage information.
–encodeCreates an ETC1 file from a PNG file. If no mode is specified, this will be the default mode for this tool.
–encodeNoHeaderCreates the original ETC1 data file (without headers) from a PNG file.
–decodeCreates a PNG file from an ETC1 file.
–showDifference diff-fileWrites the difference between the original image and the encoded image to diff-file. this option is only valid when encoding.
-o outfileSpecifies the name of the output file. If outfile is not specified, the name of the output file will consist of the name of the input file with the appropriate suffix (.pkm or .png).

etc1tool

III. zipalign

zipalign is a zip archive alignment tool that helps ensure that all uncompressed files in an archive are aligned relative to the beginning of the file.

This is done automatically if you build with Android Studio using the Android Gradle Plugin (AGP).

The following section focuses on the use of custom build systems:

3.1 Utilization

If your APK contains shared libraries (.so files), use -p to make sure they are aligned with the 4KiB page boundaries appropriate for mmap(2).
For other files (whose alignment is determined by zipalign’s mandatory alignment parameter), Android Studio will align to 4 bytes on 32-bit and 64-bit systems.

To align infile.apk and save it as outfile.apk, run the following command:

zipalign -p -f -v 4 infile.apk outfile.apk

To verify the alignment of existing.apk, use the following command. If you are building with Android Studio or AGP, you should use this command to verify that the APK is aligned.

zipalign -c -v 4 existing.apk
options (as in computer software settings)clarification
-cChecks alignment only (does not modify the file).
-fOverwrite existing output files.
-hDisplays tool help.
-pAligns uncompressed .so files to pages.
-vDetailed output.
-zUse Zopfli to recompress.

zipalign

IV. Recommended reading

Java Column

SQL Column

Data Structures and Algorithms

Android Learning Column

Android etc1tool png image conversion pkm and zipalign Introduction

Recommended Today

uniapp and applet set tabBar and show and hide tabBar

(1) Set the tabBar: uni.setTabberItem({}); wx.setTabberItem({}); indexnumberisWhich item of the tabBar, counting from the left, is indexed from 0.textstringnoButton text on tabiconPathstringnoImage PathselectedIconPathstringnoImage path when selectedpagePathstringnoPage absolute pathvisiblebooleannotab Whether to display uni.setTabBarItem({ index: 0, text: ‘text’, iconPath: ‘/path/to/iconPath’, selectedIconPath: ‘/path/to/selectedIconPath’, pagePath: ‘pages/home/home’ }) wx.setTabBarItem({ index: 0, text: ‘text’, iconPath: ‘/path/to/iconPath’, selectedIconPath: ‘/path/to/selectedIconPath’, pagePath: ‘pages/home/home’ }) […]