Functions called from Android are contained in app/src/main/cpp/libjpeg-turbo-2.1.3/ajpegtran_turbo.c
.
This sample library provide the follwoing two functions.
-
ajpegtranhead()
Get properties about specified JPEG file. -
ajpegtran()
Main function execute lossless JPEG operations.
By calling this function, the JPEG property can be get.
ajpegtranhead( JNIEnv* env, jobject thiz, jint fd, jintArray jParamArray )
- jint fd
File descripor to read JPEG file. - jintArray jParamArray
Integer array of size 10 to return parameters.
Index | Value |
---|---|
0 | Image width (pixel) |
1 | Image height (pixel) |
2 | Color component number (1,3,4) |
3 | MCU width (block) |
4 | MCU height (block) |
5 | Color space (Value is defined in jpeglib.h line 220) |
6 | Quantization value for DC of component 0 |
7 | Quantization value for DC of component 1 |
8 | Quantization value for DC of component 2 |
9 | Quantization value for DC of component 3 |
This function returns the following string.
- "OK"
Successed. - Another
Error message.
The sample application call this function before ajpegtran() always. But you can call ajpegtran() directly.
The quantization value is useful for option 'offset' about ajpegtran(). Refer explanation of option, 'offset'.
This function execute lossless operation on JPEG image.
ajpegtran( JNIEnv* env, jobject thiz, jint rfd, jint wfd, jstring jOptions )
- jint rfd
File descripor to read JPEG file. - jint wfd
File descripor to write JPEG file. - jstring jOptions
This string is for specifing option like command line below.
-optimize -copy all -crop 640x480+0+0
This function returns the following string.
- "OK"
Successed. - Another
Error message.
The following option can be used.
- copy [all|default|none]
- grayscale
- optimize
- crop
- flip [horizontal|vertical]
- roate [90|180|270]
- wipe
- restart
The following options can be used maybe.
- trim
- perfect
- transpose
- transverse
- maxmemory
Refer to IJG document about detail of the options.