mirror of
https://github.com/jneug/zeichenmaschine.git
synced 2026-10-12 01:45:18 +02:00
ImageLoader.createImage() erstellt kompatible Image-Objekte
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
package schule.ngb.zm.util;
|
package schule.ngb.zm.util;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.Color;
|
import java.awt.*;
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.RenderedImage;
|
import java.awt.image.RenderedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -148,7 +146,8 @@ public class ImageLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void saveImage( Image image, File file, boolean overwriteIfExists ) throws IOException {
|
public static void saveImage( Image image, File file, boolean overwriteIfExists ) throws IOException {
|
||||||
BufferedImage outimage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB);
|
//BufferedImage outimage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB);
|
||||||
|
BufferedImage outimage = createImage(image.getWidth(null), image.getHeight(null));
|
||||||
|
|
||||||
Graphics2D g = outimage.createGraphics();
|
Graphics2D g = outimage.createGraphics();
|
||||||
g.setColor(Color.WHITE);
|
g.setColor(Color.WHITE);
|
||||||
@@ -183,4 +182,16 @@ public class ImageLoader {
|
|||||||
ImageIO.write(image, formatName, file);
|
ImageIO.write(image, formatName, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static BufferedImage createImage( int width, int height ) {
|
||||||
|
return createImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BufferedImage createImage( int width, int height, int type ) {
|
||||||
|
return GraphicsEnvironment
|
||||||
|
.getLocalGraphicsEnvironment()
|
||||||
|
.getDefaultScreenDevice()
|
||||||
|
.getDefaultConfiguration()
|
||||||
|
.createCompatibleImage(width, height, type);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user