if (output instanceof OutputStream) {
OutputStream os = (OutputStream)output;
if (useCache) {
return new FileCacheImageOutputStream(os, cacheDir);
} else {
return new MemoryCacheImageOutputStream(os);
}
} else {
throw new IllegalArgumentException();
}