diff --git a/components/formats-bsd/src/loci/formats/in/TileJPEGReader.java b/components/formats-bsd/src/loci/formats/in/TileJPEGReader.java index a70cb2f9153..db02888542c 100644 --- a/components/formats-bsd/src/loci/formats/in/TileJPEGReader.java +++ b/components/formats-bsd/src/loci/formats/in/TileJPEGReader.java @@ -147,6 +147,7 @@ public void reopenFile() throws IOException { service = null; throw new IOException("Could not initialize JPEG service", se); } + if (!service.isLibraryLoaded()) throw new IOException("JPEG service failed to load Turbo JPEG library"); } } diff --git a/components/formats-bsd/src/loci/formats/services/JPEGTurboService.java b/components/formats-bsd/src/loci/formats/services/JPEGTurboService.java index dfdd4229432..85570cbaf2c 100644 --- a/components/formats-bsd/src/loci/formats/services/JPEGTurboService.java +++ b/components/formats-bsd/src/loci/formats/services/JPEGTurboService.java @@ -58,5 +58,7 @@ byte[] getTile(byte[] buf, int xCoordinate, int yCoordinate, int width, byte[] getTile(int xTile, int yTile) throws IOException; void close() throws IOException; + + boolean isLibraryLoaded(); } diff --git a/components/formats-bsd/src/loci/formats/services/JPEGTurboServiceImpl.java b/components/formats-bsd/src/loci/formats/services/JPEGTurboServiceImpl.java index 3231da2686b..cbe0e2033e3 100644 --- a/components/formats-bsd/src/loci/formats/services/JPEGTurboServiceImpl.java +++ b/components/formats-bsd/src/loci/formats/services/JPEGTurboServiceImpl.java @@ -106,9 +106,6 @@ public JPEGTurboServiceImpl() { logger.setLevel(Level.SEVERE); if (!libraryLoaded) { libraryLoaded = NativeLibraryUtil.loadNativeLibrary(TJ.class, "turbojpeg"); - if (!libraryLoaded) { - throw new RuntimeException("TurboJPEG could not be loaded"); - } } } @@ -383,6 +380,11 @@ public void close() throws IOException { header = null; } + @Override + public boolean isLibraryLoaded() { + return libraryLoaded; + } + // -- Helper methods -- private byte[] getFixedHeader() throws IOException { diff --git a/components/formats-gpl/src/loci/formats/in/HamamatsuVMSReader.java b/components/formats-gpl/src/loci/formats/in/HamamatsuVMSReader.java index 34fa3c0d0a8..d54ecbeeba7 100644 --- a/components/formats-gpl/src/loci/formats/in/HamamatsuVMSReader.java +++ b/components/formats-gpl/src/loci/formats/in/HamamatsuVMSReader.java @@ -157,6 +157,7 @@ public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) if (service == null) { service = new JPEGTurboServiceImpl(); + if (!service.isLibraryLoaded()) throw new IOException("JPEG service failed to load Turbo JPEG library"); } try { diff --git a/components/formats-gpl/src/loci/formats/in/NDPIReader.java b/components/formats-gpl/src/loci/formats/in/NDPIReader.java index 6da4236d697..32fc44d20df 100644 --- a/components/formats-gpl/src/loci/formats/in/NDPIReader.java +++ b/components/formats-gpl/src/loci/formats/in/NDPIReader.java @@ -329,6 +329,7 @@ public int getOptimalTileHeight() { /* @see loci.formats.FormatReader#initFile(String) */ @Override protected void initFile(String id) throws FormatException, IOException { + if (!service.isLibraryLoaded()) throw new IOException("JPEG service failed to load Turbo JPEG library"); RandomAccessInputStream s = new RandomAccessInputStream(id); use64Bit = s.length() >= Math.pow(2, 32); s.close();