#837: Now uses last app segment for color space detection.

This commit is contained in:
Harald Kuhr 2023-10-18 16:52:47 +02:00
parent 57680f1bec
commit 2c7c47b158
2 changed files with 9 additions and 8 deletions

View File

@ -888,20 +888,21 @@ public final class JPEGImageReader extends ImageReaderBase {
throw new IIOException("No SOF segment in stream"); throw new IIOException("No SOF segment in stream");
} }
private Application lastAppSegment(int marker, String identifier) throws IOException {
List<Application> appSegments = getAppSegments(marker, identifier);
return appSegments.isEmpty() ? null : appSegments.get(appSegments.size() - 1);
}
AdobeDCT getAdobeDCT() throws IOException { AdobeDCT getAdobeDCT() throws IOException {
List<Application> adobe = getAppSegments(JPEG.APP14, "Adobe"); return (AdobeDCT) lastAppSegment(JPEG.APP14, "Adobe");
return adobe.isEmpty() ? null : (AdobeDCT) adobe.get(0);
} }
JFIF getJFIF() throws IOException{ JFIF getJFIF() throws IOException{
List<Application> jfif = getAppSegments(JPEG.APP0, "JFIF"); return (JFIF) lastAppSegment(JPEG.APP0, "JFIF");
return jfif.isEmpty() ? null : (JFIF) jfif.get(0);
} }
JFXX getJFXX() throws IOException { JFXX getJFXX() throws IOException {
List<Application> jfxx = getAppSegments(JPEG.APP0, "JFXX"); return (JFXX) lastAppSegment(JPEG.APP0, "JFXX");
return jfxx.isEmpty() ? null : (JFXX) jfxx.get(0);
} }
private EXIF getExif() throws IOException { private EXIF getExif() throws IOException {

View File

@ -52,7 +52,7 @@ import static com.twelvemonkeys.imageio.util.IIOUtil.lookupProviderByName;
* @version $Id: JPEGImageReaderSpi.java,v 1.0 24.01.11 22.12 haraldk Exp$ * @version $Id: JPEGImageReaderSpi.java,v 1.0 24.01.11 22.12 haraldk Exp$
*/ */
public final class JPEGImageReaderSpi extends ImageReaderSpiBase { public final class JPEGImageReaderSpi extends ImageReaderSpiBase {
protected ImageReaderSpi delegateProvider; ImageReaderSpi delegateProvider;
/** /**
* Constructor for use by {@link javax.imageio.spi.IIORegistry} only. * Constructor for use by {@link javax.imageio.spi.IIORegistry} only.