README 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. TurboJPEG Java Wrapper
  2. ======================
  3. The TurboJPEG shared library can optionally be built with a Java Native
  4. Interface wrapper, which allows the library to be loaded and used directly from
  5. Java applications. The Java front end for this is defined in several classes
  6. located under org/libjpegturbo/turbojpeg. The source code for these Java
  7. classes is licensed under a BSD-style license, so the files can be incorporated
  8. directly into both open source and proprietary projects without restriction. A
  9. Java archive (JAR) file containing these classes is also shipped with the
  10. "official" distribution packages of libjpeg-turbo.
  11. TJExample.java, which should also be located in the same directory as this
  12. README file, demonstrates how to use the TurboJPEG Java API to compress and
  13. decompress JPEG images in memory.
  14. Performance Pitfalls
  15. --------------------
  16. The TurboJPEG Java API defines several convenience methods that can allocate
  17. image buffers or instantiate classes to hold the result of compress,
  18. decompress, or transform operations. However, if you use these methods, then
  19. be mindful of the amount of new data you are creating on the heap. It may be
  20. necessary to manually invoke the garbage collector to prevent heap exhaustion
  21. or to prevent performance degradation. Background garbage collection can kill
  22. performance, particularly in a multi-threaded environment (Java pauses all
  23. threads when the GC runs.)
  24. The TurboJPEG Java API always gives you the option of pre-allocating your own
  25. source and destination buffers, which allows you to re-use those buffers for
  26. compressing/decompressing multiple images. If the image sequence you are
  27. compressing or decompressing consists of images of the same size, then
  28. pre-allocating the buffers is recommended.
  29. Installation Directory
  30. ----------------------
  31. The TurboJPEG Java Wrapper will look for the TurboJPEG JNI library
  32. (libturbojpeg.so, libturbojpeg.jnilib, or turbojpeg.dll) in the system library
  33. paths or in any paths specified in LD_LIBRARY_PATH (Un*x), DYLD_LIBRARY_PATH
  34. (Mac), or PATH (Windows.) Failing this, on Un*x and Mac systems, the wrapper
  35. will look for the JNI library under the library directory configured when
  36. libjpeg-turbo was built. If that library directory is
  37. /opt/libjpeg-turbo/lib32, then /opt/libjpeg-turbo/lib64 is also searched, and
  38. vice versa.
  39. If you installed the JNI library into another directory, then you will need
  40. to pass an argument of -Djava.library.path={path_to_JNI_library} to java, or
  41. manipulate LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, or PATH to include the directory
  42. containing the JNI library.