mirror of
https://github.com/geekwenjie/SmartJavaAI.git
synced 2026-09-10 03:28:49 +00:00
@@ -24,6 +24,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.file.Path;
|
||||
@@ -147,6 +148,19 @@ public class SmartImageFactory {
|
||||
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