TJCompressor.compress(): Fix lossls buf size calc

This commit is contained in:
DRC
2024-08-23 12:48:01 -04:00
parent 0acb084464
commit de4bbac55e
2 changed files with 7 additions and 0 deletions

View File

@@ -28,6 +28,11 @@ unless the `-precision` option was specified before the `-lossless` option.
calling applications to generate 12-bit-per-sample arithmetic-coded lossy JPEG
images using the TurboJPEG API.
5. Fixed an error ("Destination buffer is not large enough") that occurred when
attempting to generate a full-color lossless JPEG image using the TurboJPEG
Java API's `byte[] TJCompressor.compress()` method if the value of
`TJ.PARAM_SUBSAMP` was not `TJ.SAMP_444`.
3.0.3
=====

View File

@@ -485,6 +485,8 @@ public class TJCompressor implements Closeable {
} else {
checkSubsampling();
int subsamp = get(TJ.PARAM_SUBSAMP);
if (get(TJ.PARAM_LOSSLESS) == 1 && subsamp != TJ.SAMP_GRAY)
subsamp = TJ.SAMP_444;
buf = new byte[TJ.bufSize(srcWidth, srcHeight, subsamp)];
}
compress(buf);