TJCompressor.compress(int): Fix YUV-to-JPEG error
Due to an oversight, the TJCompressor.compress(int) method did not handle YUV source images. Fixes #413
This commit is contained in:
@@ -8,6 +8,11 @@ in the MIPS DSPr2 SIMD extensions are now disabled until/unless they can be
|
|||||||
fixed, and other functions that are incompatible with big endian MIPS CPUs are
|
fixed, and other functions that are incompatible with big endian MIPS CPUs are
|
||||||
disabled when building libjpeg-turbo for such CPUs.
|
disabled when building libjpeg-turbo for such CPUs.
|
||||||
|
|
||||||
|
2. Fixed an oversight in the `TJCompressor.compress(int)` method in the
|
||||||
|
TurboJPEG Java API that caused an error ("java.lang.IllegalStateException: No
|
||||||
|
source image is associated with this instance") when attempting to use that
|
||||||
|
method to compress a YUV image.
|
||||||
|
|
||||||
|
|
||||||
2.0.4
|
2.0.4
|
||||||
=====
|
=====
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C)2011-2015, 2018 D. R. Commander. All Rights Reserved.
|
* Copyright (C)2011-2015, 2018, 2020 D. R. Commander. All Rights Reserved.
|
||||||
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
|
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -377,8 +377,15 @@ public class TJCompressor implements Closeable {
|
|||||||
* #getCompressedSize} to obtain the size of the JPEG image.
|
* #getCompressedSize} to obtain the size of the JPEG image.
|
||||||
*/
|
*/
|
||||||
public byte[] compress(int flags) throws TJException {
|
public byte[] compress(int flags) throws TJException {
|
||||||
checkSourceImage();
|
byte[] buf;
|
||||||
byte[] buf = new byte[TJ.bufSize(srcWidth, srcHeight, subsamp)];
|
if (srcYUVImage != null) {
|
||||||
|
buf = new byte[TJ.bufSize(srcYUVImage.getWidth(),
|
||||||
|
srcYUVImage.getHeight(),
|
||||||
|
srcYUVImage.getSubsamp())];
|
||||||
|
} else {
|
||||||
|
checkSourceImage();
|
||||||
|
buf = new byte[TJ.bufSize(srcWidth, srcHeight, subsamp)];
|
||||||
|
}
|
||||||
compress(buf, flags);
|
compress(buf, flags);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user