Android native C Development 7: libjpeg porting notes

Source: Internet
Author: User
Tags bmp image

From: http://blog.sina.com.cn/s/blog_4a0a39c30100ckzd.html



JPEG is the abbreviation of joint photographic Experts Group (joint image expert group). The file is named ". jpg "or ". JPEG is a common image file format on the Internet. It is famous for its small size, but its biggest drawback is that it is a lossy compression image format, images can be compressed to a small storage space, and duplicate or unimportant data in images will be lost, which may easily cause damage to image data. In particular, the use of a high compression ratio will significantly reduce the quality of the restored image after the final decompression. If the pursuit of high-quality images, it is not appropriate to use a high compression ratio. However, the JPEG compression technology is very advanced. It uses lossy compression to remove redundant image data and can present rich and vivid images while obtaining an extremely high compression ratio. In other words, that is, you can use the least disk space to get better image quality.

As an upgraded version of JPEG, the compression rate is about 30% higher than that of JPEG, and lossy and lossless compression is supported. One of the most important features of the MPEG-4 format is that it can achieve progressive transmission, that is, first transmission of the image contour, and then gradually transmission of data to continuously improve the image quality, so that the image can be clearly displayed from the haze. In addition, it supports the so-called "regions of interest" feature. You can specify the compression quality of the regions of interest on the image, and extract the specified part first.

This article only discusses the encoding and decoding of JPEG, not including the 2000. if you are interested, you can find some information on the Internet.

JPEG official website (http://www.jpeg.org) is not responsible for JPEG file encoding and decoding implementation, but to develop standards, huh, should be that sentence: first-class manufacturers set standards. Source code of JPEG can be downloaded from ijg (independent JPEG group, independent JPEG group) Website: http://www.ijg.org:
Http://www.ijg.org/files/jpegsrc.v6b.tar.gz,
For Windows, use the following ZIP format:
Ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/jpegsr6.zip.

Decompress it, a directory: jpeg-6b, see the file jversion under the directory. h. We found that the version of the JPEG library is 6B 27-Mar-1998. We can see how old and stable this library is. It was just over 10 years ago!

After the solution is completed, the first step is to change the old rule to makefile, copy makefile. ANSI, change it to makefile, and change it to the following line:
#09: CC = arm-None-Linux-gnueabi-gcc
Change the GCC compiler to Android arm.
#12: cflags =-O2
The optimization code is said to be-O2 (note the letter "O", not the number "0") in terms of size and efficiency is better.
#17: ldflags =-S-static
The Link parameter-static is required for Android native, and-S is used to remove debugging information from the small library size.
#33: Ar = arm-None-Linux-gnueabi-ar RC
#35: AR2 = arm-None-Linux-gnueabi-ranlib
Replace the AR and AR2 library package with Android native.

Enter make in cygwin.
Haha, so worried. The following prompt is displayed:
You must prepare a system-dependent jconfig. h file.
Please read the installation directions ctions in install.doc.

That is to say, jconfig. h does not exist. We need to prepare one for compilation. Once I found it again, I did not find it suitable for Unix/Linux. I directly opened jconfig.doc, copied all the content, and saved it into jconfig. H, because it contains a detailed macro definition introduction. Of course, you can open all macro definitions and try again one by one. If any problem occurs, cancel the macro definition.

Input: Make
Everything is okay, and the executable files of libjpeg. A and andorid native are obtained: cjpeg, djpeg, mongotran, rdjpgcom, and wrjpgcom. You can see that cjpeg is the compressor of a jpeg file, and other files are compressed into JPEG format. djpeg must have been decompressed and uploaded to Android emulator!
(">" Is a common command prompt, and "#" is a simulator command prompt)
> ADB push cjpeg/dev/sample/cjpeg
> ADB push testimg.bmp/dev/sample/testimg.bmp
> ADB Shell
# Cd/dev/sample
# Chmod 777 cjpeg
#./Cjpeg-quality 90-OUTFILE testimg.jpg testimg.bmp
# Exit
> ADB pull/dev/sample/testimg.jpg

Push cjpeg and testimg.bmp to the simulator, and then execute cjpeg to obtain the compressed image testimg.jpg. It is found that the size of a high-quality (Quality = 90) jpg image is about 25% of that of a BMP image. If you are interested, you can try djpeg and other testing programs.
The following is a JPG file compressed by the android simulator.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.