blob: 22e0f738410e3cf760433d40f0f03f5087aa67e2 [file] [log] [blame]
DRC279bd342011-04-02 05:17:12 +00001TurboJPEG/OSS Java Wrapper
2==========================
DRCf8e00552011-02-04 11:06:36 +00003
4TurboJPEG/OSS can optionally be built with a Java Native Interface wrapper,
5which allows the TurboJPEG/OSS dynamic library to be loaded and used directly
DRCc5a41992011-02-08 06:54:36 +00006from Java applications. The Java front end for this is defined in several
7classes located under org/libjpegturbo/turbojpeg. The source code for these
8Java classes is licensed under a BSD-style license, so the files can be
DRCf8e00552011-02-04 11:06:36 +00009incorporated directly into both open source and proprietary projects without
DRC279bd342011-04-02 05:17:12 +000010restriction. A Java archive (JAR) file containing these classes is also
11shipped with the "official" distribution packages of libjpeg-turbo.
DRCf8e00552011-02-04 11:06:36 +000012
DRC2413cb82011-02-08 02:11:37 +000013TJExample.java, which should also be located in the same directory as this
DRCf8e00552011-02-04 11:06:36 +000014README file, demonstrates how to use the TurboJPEG/OSS Java front end to
15compress and decompress JPEG images in memory.
16
DRCf8e00552011-02-04 11:06:36 +000017
DRC7c998222011-03-10 07:25:41 +000018Performance Pitfalls
19--------------------
20
DRC80803ae2011-12-15 13:12:59 +000021The TurboJPEG Java front end defines several convenience methods that can
DRC7c998222011-03-10 07:25:41 +000022allocate image buffers or instantiate classes to hold the result of compress,
23decompress, or transform operations. However, if you use these methods, then
24be mindful of the amount of new data you are creating on the heap. It may be
25necessary to manually invoke the garbage collector to prevent heap exhaustion
26or to prevent performance degradation. Background garbage collection can kill
27performance, particularly in a multi-threaded environment (Java pauses all
28threads when the GC runs.)
29
30The Java front end always gives you the option of pre-allocating your own
31source and destination buffers, which allows you to re-use these buffers for
32compressing/decompressing multiple images. If the image sequence you are
33compressing or decompressing consists of images of the same size, then
34pre-allocating the buffers is recommended.
35
36
DRCf8e00552011-02-04 11:06:36 +000037Note for OS X users
38-------------------
39
40/usr/lib, the directory under which libturbojpeg.dylib is installed on Mac
41systems, is not part of the normal Java library path. Thus, when running a
42Java application that uses TurboJPEG/OSS on Mac systems, you will need to pass
43an argument of -Djava.library.path=/usr/lib to java.
DRCed6526f2011-02-05 05:41:18 +000044
45
46Note for Solaris users
47----------------------
48
49/opt/libjpeg-turbo/lib, the directory under which libturbojpeg.so is installed
50on Solaris systems, is not part of the normal Java library path. Thus, when
51running a Java application that uses TurboJPEG/OSS on Solaris systems, you will
52need to pass an argument of -Djava.library.path=/opt/libjpeg-turbo/lib to java.
53If using a 64-bit data model, then instead pass an argument of
54-Djava.library.path=/opt/libjpeg-turbo/lib/amd64 to use the 64-bit version of
55libturbojpeg.so.