mirror of
https://github.com/geekwenjie/SmartJavaAI.git
synced 2026-09-11 20:28:56 +00:00
@@ -24,6 +24,7 @@ import java.io.ByteArrayInputStream;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.URL;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@@ -147,6 +148,19 @@ public class SmartImageFactory {
|
|||||||
return ImageFactory.getInstance().fromInputStream(inputStream);
|
return ImageFactory.getInstance().fromInputStream(inputStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Image fromUrl(URL url) throws IOException {
|
||||||
|
if (url == null) {
|
||||||
|
throw new IllegalArgumentException("URL 不能为空");
|
||||||
|
}
|
||||||
|
try (InputStream inputStream = url.openStream()) {
|
||||||
|
return ImageFactory.getInstance().fromInputStream(inputStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image fromUrl(String urlString) throws IOException {
|
||||||
|
return this.fromUrl(new URL(urlString));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user