mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2025-01-04 07:28:17 +01:00
Converting the image seems to fix the jvm bug
This commit is contained in:
parent
7d24236dfe
commit
4259656cda
@ -29,7 +29,6 @@ import java.awt.image.BufferedImage;
|
|||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileFilter;
|
import java.io.FileFilter;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@ -604,14 +603,7 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static BufferedImage readImage(InputStream in) throws IOException {
|
public static BufferedImage readImage(InputStream in) throws IOException {
|
||||||
try (DataInputStream dis = new DataInputStream(new BufferedInputStream(in, 1024))) {
|
return MainUtil.toRGB(ImageIO.read(in));
|
||||||
dis.mark(1024);
|
|
||||||
boolean jpeg = dis.readInt() == 0xffd8ffe0;
|
|
||||||
dis.reset();
|
|
||||||
BufferedImage img = ImageIO.read(dis);
|
|
||||||
if (jpeg) img = toRGB(img);
|
|
||||||
return img;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BufferedImage readImage(URL url) throws IOException {
|
public static BufferedImage readImage(URL url) throws IOException {
|
||||||
@ -624,7 +616,7 @@ public class MainUtil {
|
|||||||
|
|
||||||
public static BufferedImage toRGB(BufferedImage src) {
|
public static BufferedImage toRGB(BufferedImage src) {
|
||||||
if (src == null) return src;
|
if (src == null) return src;
|
||||||
BufferedImage img = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_INT_BGR);
|
BufferedImage img = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_INT_ARGB);
|
||||||
Graphics2D g2d = img.createGraphics();
|
Graphics2D g2d = img.createGraphics();
|
||||||
g2d.drawImage(src, 0, 0, null);
|
g2d.drawImage(src, 0, 0, null);
|
||||||
g2d.dispose();
|
g2d.dispose();
|
||||||
|
Loading…
Reference in New Issue
Block a user