mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-05 04:25:29 -04:00
Made JPEG lossless decoding seemingly much faster.
This commit is contained in:
parent
4f659e41bf
commit
65e3156429
@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
package com.twelvemonkeys.imageio.plugins.jpeg;
|
package com.twelvemonkeys.imageio.plugins.jpeg;
|
||||||
|
|
||||||
|
import com.twelvemonkeys.imageio.stream.BufferedImageInputStream;
|
||||||
|
|
||||||
import javax.imageio.stream.ImageInputStream;
|
import javax.imageio.stream.ImageInputStream;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.DataBufferByte;
|
import java.awt.image.DataBufferByte;
|
||||||
@ -67,7 +69,7 @@ final class JPEGLosslessDecoderWrapper {
|
|||||||
* @throws IOException is thrown if the decoder failed or a conversion is not supported
|
* @throws IOException is thrown if the decoder failed or a conversion is not supported
|
||||||
*/
|
*/
|
||||||
BufferedImage readImage(final List<Segment> segments, final ImageInputStream input) throws IOException {
|
BufferedImage readImage(final List<Segment> segments, final ImageInputStream input) throws IOException {
|
||||||
JPEGLosslessDecoder decoder = new JPEGLosslessDecoder(segments, input);
|
JPEGLosslessDecoder decoder = new JPEGLosslessDecoder(segments, createBufferedInput(input));
|
||||||
|
|
||||||
int[][] decoded = decoder.decode();
|
int[][] decoded = decoder.decode();
|
||||||
int width = decoder.getDimX();
|
int width = decoder.getDimX();
|
||||||
@ -99,6 +101,10 @@ final class JPEGLosslessDecoderWrapper {
|
|||||||
throw new IOException("JPEG Lossless with " + decoder.getPrecision() + " bit precision and " + decoder.getNumComponents() + " component(s) cannot be decoded");
|
throw new IOException("JPEG Lossless with " + decoder.getPrecision() + " bit precision and " + decoder.getNumComponents() + " component(s) cannot be decoded");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ImageInputStream createBufferedInput(final ImageInputStream input) throws IOException {
|
||||||
|
return input instanceof BufferedImageInputStream ? input : new BufferedImageInputStream(input);
|
||||||
|
}
|
||||||
|
|
||||||
Raster readRaster(final List<Segment> segments, final ImageInputStream input) throws IOException {
|
Raster readRaster(final List<Segment> segments, final ImageInputStream input) throws IOException {
|
||||||
// TODO: Can perhaps be implemented faster
|
// TODO: Can perhaps be implemented faster
|
||||||
return readImage(segments, input).getRaster();
|
return readImage(segments, input).getRaster();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user