}
// Write the given preview to the cache
final String key = getImageKey(file);
try {
final OutputStream out = cache.putToStream(key);
final OutputStreamImageDataReceiver receiver =
new OutputStreamImageDataReceiver(out);
try {
final LCJPEGWriter writer = new LCJPEGWriter(
receiver, 32 * 1024,
image.getWidth(), image.getHeight(),
image.getColorModel().getNumComponents(),
CS_RGB, 90
);
writer.putImage(image);
writer.dispose();
}
catch (LCImageLibException e) {
logNonFatalStatic(file, e, "caching preview");
cache.remove(key);
}
out.close();
receiver.dispose();
}
catch (IOException e) {
logNonFatalStatic(file, e, "caching preview");
removeCacheSilentStatic(cache, file);
}