mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-15 01:08:35 +00:00
Use Uri instead of BufferedImage for parameter
This commit is contained in:
@ -1,9 +1,12 @@
|
||||
package com.boydti.fawe.util.image;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.command.FawePrimitiveBinding;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.worldedit.util.command.parametric.ParameterException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Transparency;
|
||||
@ -156,6 +159,23 @@ public class ImageUtil {
|
||||
return (alpha << 24) + (red << 16) + (green << 8) + (blue << 0);
|
||||
}
|
||||
|
||||
public static BufferedImage load(@Nullable FawePrimitiveBinding.ImageUri uri) throws ParameterException {
|
||||
return uri == null ? null : uri.load();
|
||||
}
|
||||
|
||||
public static BufferedImage load(URI uri) throws ParameterException {
|
||||
try {
|
||||
String uriStr = uri.toString();
|
||||
if (uriStr.startsWith("file:/")) {
|
||||
File file = new File(uri.getPath());
|
||||
return MainUtil.readImage(file);
|
||||
}
|
||||
return MainUtil.readImage(new URL(uriStr));
|
||||
} catch (IOException e) {
|
||||
throw new ParameterException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static BufferedImage getImage(String arg) throws ParameterException {
|
||||
try {
|
||||
if (arg.startsWith("http")) {
|
||||
|
Reference in New Issue
Block a user