JDK-8100250 : Use subsampling to improve performance of thumbnail creation
  • Type: Sub-task
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: fx1.2
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2008-11-22
  • Updated: 2015-06-16
  • Resolved: 2009-10-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
fx1.3Fixed
Description
We should use ImageReadParam.setSourceSubsampling() in the ImageLoader.readImageFromStream() code to improve performance of creating thumbnails from large JPEG image files.  The idea is that we can use subsampling to reduce the initial cost of reading the image (and reduce memory consumption) and then use the usual multi-step downscaling algorithm for the remaining part of the process so that we still produce a high-quality thumbnail.

For example, creating a 80x60 thumbnail from a 4000x3000 pixel image, we can use 8:8 subsampling so that Image I/O reads a 500x375 image, and then we use the multi-step algorithm to scale that down into an 80x60 thumbnail image.

We'll need to experiment to find the right balance between speed and quality.

Also, there is some overlap here with RT-2365... It appears that the CLibJPEGImageReader from JAI IIO Tools does not support native subsampling, so enabling can actually result in slower reading than not using it at all.  If we are to pursue RT-2365, we'll need to add native subsampling support there first.
Comments
Fixed by the JPEGImageLoader in the javafx-iio and javafx-iio-native sub-projects of soma/scrum/graphics/runtime. The solution is similar to but not exactly the same as that proposed in the issue description. It is similar in that a two-step algorithm is used to generate the result. It differs in the algorithm used in each step. In the first step, instead of subsampling, DCT scaling is used to generate an intermediate image with the same aspect ratio as the source image but of size M/8 where 1 <= M <= 7. This step is performed by the native libjpeg. In the second step, the line-by-line Downscaler is used to generate the final image from the intermediate image.
16-10-2009

Assigning to Brian just so we can take it into account in the work for RT-5322. Most likely we'll just enable this in the new image loader but not port it to the IIO-based image loader, at which point we can consider closing this issue.
12-08-2009

With JDK 6 (on the same machine, my MacBook Pro, 2.4 GHz Core2Duo) the numbers are even more impressive: TESTING: file:/Users/campbell/Projects/Sun/tmp/gorilla.jpg create stream: 0 find reader: 1 get num images: 0 read: 476 scale: 1 close stream: 0 remove listeners: 0 dispose reader: 0 readImage: 478 total: 478ms TESTING: file:/Users/campbell/Projects/Sun/tmp/flower2.jpg create stream: 0 find reader: 4 get num images: 0 read: 366 scale: 0 close stream: 0 remove listeners: 0 dispose reader: 0 readImage: 371 total: 372ms
23-11-2008

With all the fixes from RT-2363 in place we had: TESTING: file:/Users/campbell/Projects/Sun/tmp/gorilla.jpg create stream: 0 find reader: 1 get num images: 0 read: 1312 scale: 101 close stream: 0 remove listeners: 0 dispose reader: 0 readImage: 1414 total: 1415ms TESTING: file:/Users/campbell/Projects/Sun/tmp/flower2.jpg create stream: 0 find reader: 1 get num images: 0 read: 1213 scale: 101 close stream: 1 remove listeners: 0 dispose reader: 0 readImage: 1316 total: 1316ms With 8:8 subsampling, we end up with: TESTING: file:/Users/campbell/Projects/Sun/tmp/gorilla.jpg create stream: 0 find reader: 0 get num images: 0 read: 671 scale: 4 close stream: 0 remove listeners: 0 dispose reader: 0 readImage: 676 total: 676ms TESTING: file:/Users/campbell/Projects/Sun/tmp/flower2.jpg create stream: 1 find reader: 0 get num images: 0 read: 595 scale: 3 close stream: 0 remove listeners: 0 dispose reader: 0 readImage: 600 total: 600ms
23-11-2008