Original article: http://blog.sina.com.cn/s/blog_4a0a39c30100b8w6.html
Libpng (http://www.libpng.org/) is to read PNG (portable network graphic
Format) file is the most official function library, so before introducing LibPNG, it is necessary to introduce the PNG file.
PNG is an image file storage format developed in the middle of 1990s. It aims to replace GIF and TIFF file formats and add features not available in GIF file formats. Portable
Network graphic format, PNG) name is from the unofficial "PNG's not GIF", is a bitmap
File) storage format, read as "ping ". When PNG is used to store a grayscale image, the depth of the grayscale image can be up to 16 bits. When the color image is stored, the depth of the color image can be up to 48 bits, it can also store up to 16-bit alpha channel data. PNG uses the lossless data compression algorithm derived from lz77.
PNG uses lossless data compression algorithms. The compression library used is the zlib introduced in the previous article. zlib must be compiled before libpng is compiled (see the previous article: Native Android) c Development 5: zlib porting notes ).
Download the latest libpng version from SourceForge: 1.2.33. Select without config.
Script version: bz2 format, zip format, this version does not have a configure file, because basically do not need to change the libpng settings, it can be compiled through.
Unbind the downloaded source code package, get a directory named libpng-1.2.33, copy scripts/makefile. GCC
Libpng-1.2.33/makefile, change the lines 8-27 of this file to the following (bold to add ):
... Zlibinc = ../zlib-1.2.3 Zliblib = ../zlib-1.2.3# Compiler, linker, lib and other tools Cc = arm-None-Linux-gnueabi-gcc LD = $ (cc) Ar_rc = arm-None-Linux-gnueabi-ar RCS Ranlib = arm-None-Linux-gnueabi-ranlib Rm_f = Rm-F Cdebug =-g-dpng_debug = 5 Lddebug = Crelease =-O2 Ldrelease =-S-static # Cflags =-w-wall $ (cdebug) Cflags =-w-wall $ (crelease) # Ldflags = $ (lddebug) Ldflags = $ (ldrelease) Libs =-LZ-LM ... |
Enter the libpng-1.2.33 directory in cygwin or Linux Command Line and enter: Make
You can compile libpng successfully. The static Library libpng. A and the executable file pngtest will be obtained.
Use the emulator-noskin command to start android
Simulator, upload the pngtest to the simulator to test the pngtest:
$ ADB shell mkdir/dev/sample $ ADB push pngtest/dev/sample $ ADB push pngtest.png/dev/sample $ ADB shell chmod 777/dev/sample/pngtest $ ADB Shell # Cd/dev/sample #./Pngtest pngtest.png Testing libpng version 1.2.33 With Zlib version 1.2.3Libpng version 1.2.33-October 31,200 8 Copyright (c) 1998-2008 Glenn Randers-pehrson Copyright (c) 1996-1997 Andreas dilger Copyright (c) 1995-1996 guy Eric schalnat, group 42, Inc. Library (10233): LibPNG version 1.2.33-October 31,200 8 Pngtest (10233): LibPNG version 1.2.33-October 31,200 8 Sizeof (png_struct) = 984, Sizeof (png_info) = 288 Testing pngtest.png: Pass 0: rwrwrwrwrwrwrwrwrwrwrw Pass 1: rwrwrwrwrwrwrwrwrwrwrw Pass 2: rwrwrwrwrwrwrwrwrw Pass 3: Rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw Pass 4: Rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw Pass 5: Rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
Rwrwrwrw Pass 6: Rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
Rwrwrwrwrw Pass (9782 zero samples) Filter 0 was used 21 times Filter 1 was used 15 times Filter 2 was used 52 times Filter 3 was used 10 times Filter 4 was used 33 times Time = 7 Jun 1996 17:58:08 + 0000 Libpng passes test |
The command prompt "$" is cygwin, and "#" is the command prompt of ADB shell, as shown in the test: