ImageLoaderFactory[] loaderFactories = registry.getImageLoaderFactories(
imageInfo, targetFlavor);
if (loaderFactories != null) {
//Directly load image and return it
ImageLoader loader;
if (loaderFactories.length == 1) {
loader = loaderFactories[0].newImageLoader(targetFlavor);
} else {
int count = loaderFactories.length;
ImageLoader[] loaders = new ImageLoader[count];
for (int i = 0; i < count; i++) {
loaders[i] = loaderFactories[i].newImageLoader(targetFlavor);
}
loader = new CompositeImageLoader(loaders);
}
ImageProviderPipeline pipeline = new ImageProviderPipeline(manager.getCache(), loader);
candidates.add(pipeline);
} else {
//Need to use ImageConverters
if (log.isTraceEnabled()) {
log.trace("No ImageLoaderFactory found that can load this format ("
+ targetFlavor + ") directly. Trying ImageConverters instead...");
}
ImageRepresentation destination = new ImageRepresentation(targetFlavor);
//Get Loader for originalMIME
// --> List of resulting flavors, possibly multiple loaders
loaderFactories = registry.getImageLoaderFactories(originalMime);
if (loaderFactories != null) {
//Find best pipeline -> best loader
for (int i = 0, ci = loaderFactories.length; i < ci; i++) {
ImageLoaderFactory loaderFactory = loaderFactories[i];
ImageFlavor[] flavors = loaderFactory.getSupportedFlavors(originalMime);
for (int j = 0, cj = flavors.length; j < cj; j++) {
ImageProviderPipeline pipeline = findPipeline(dir, flavors[j], destination);
if (pipeline != null) {
ImageLoader loader = loaderFactory.newImageLoader(flavors[j]);
pipeline.setImageLoader(loader);
candidates.add(pipeline);
}
}
}