Class OpenSlideLoader
java.lang.Object
qupath.lib.images.servers.openslide.jna.OpenSlideLoader
Static helper class to manage loading the OpenSlide library.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
detectVendor
(String path) Try to detect the vendor of the image at the specified path.static String
Get the version of the OpenSlide library.static boolean
Query whether OpenSlide has already been loaded.static OpenSlide
Open an image using OpenSlide, returning an OpenSlide instance to access pixels and metadata.static boolean
Try to load OpenSlide.static boolean
tryToLoadQuietly
(String... searchPath) Try to load OpenSlide, but don't throw an exception if it fails.
-
Constructor Details
-
OpenSlideLoader
public OpenSlideLoader()
-
-
Method Details
-
tryToLoadQuietly
Try to load OpenSlide, but don't throw an exception if it fails.- Parameters:
searchPath
- optional search paths that may be provided to assist with finding the preferred library.- Returns:
- true if OpenSlide was loaded successfully, false otherwise.
-
tryToLoad
Try to load OpenSlide. This is liable to throw an exception if the library cannot be loaded.- Parameters:
searchPath
- optional search paths that may be provided to assist with finding the preferred library.- Returns:
- true if OpenSlide was loaded successfully, false otherwise.
- Throws:
UnsatisfiedLinkError
-
getLibraryVersion
Get the version of the OpenSlide library. This will attempt to load OpenSlide if it is not already available.- Returns:
- a version string for the library, or null if the library is not available
-
isOpenSlideAvailable
public static boolean isOpenSlideAvailable()Query whether OpenSlide has already been loaded. This will not attempt to load the library; for that, use #tryToLoadQuietly(),getLibraryVersion()
ortryToLoad(String...)
.- Returns:
- true if OpenSlide has been loaded successfully, false otherwise
-
openImage
Open an image using OpenSlide, returning an OpenSlide instance to access pixels and metadata.This will attempt to load OpenSlide if it has not already been loaded, throwing an
IOException
if this fails. UseisOpenSlideAvailable()
to check whether OpenSlide is available before calling this.- Parameters:
path
- the image path (usually an absolute file path)- Returns:
- an OpenSlide instance
- Throws:
IOException
- if OpenSlide could not be loaded failed to open the file
-
detectVendor
Try to detect the vendor of the image at the specified path. This will attempt to load OpenSlide if it has not already been loaded.- Parameters:
path
- the image path (usually an absolute file path)- Returns:
- a vendor string if available, or null if OpenSlide could not be loaded or does not recognize the file
-