P_H_I_L
Erfahrenes Mitglied
Bekomme es einfach nciht hin :-(
die funktion, die ich geschickt habe ruft wiederum eine funktion auf. und genau an dieser Stelle verabschiedet er sich.
GraphicsConfiguration gc = getDefaultConfiguration();
Das ist die funktion
Was könnte den noch fehlen?
habe alles wie in der anleitung gemacht...
Lg,
Phil
die funktion, die ich geschickt habe ruft wiederum eine funktion auf. und genau an dieser Stelle verabschiedet er sich.
GraphicsConfiguration gc = getDefaultConfiguration();
Das ist die funktion
Code:
public static BufferedImage resizeJava2DNative(BufferedImage source, int destWidth, int destHeight,
Object interpolation) {
System.out.print("1");
if (source == null) {
System.out.print("2");
throw new NullPointerException("source image is NULL!");
}
if (destWidth <= 0 && destHeight <= 0) {
System.out.print("3");
throw new IllegalArgumentException("destination width & height are both <=0!");
}
int sourceWidth = source.getWidth();
System.out.print("4");
int sourceHeight = source.getHeight();
System.out.print("5");
double xScale = ((double) destWidth) / (double) sourceWidth;
double yScale = ((double) destHeight) / (double) sourceHeight;
System.out.print("6");
if (destWidth <= 0) {
System.out.print("7");
xScale = yScale;
destWidth = (int) Math.rint(xScale * sourceWidth);
System.out.print("8");
}
if (destHeight <= 0) {
System.out.print("9:"+yScale);
yScale = xScale;
destHeight = (int) Math.rint(yScale * sourceHeight);
System.out.print("10");
}
GraphicsConfiguration gc = getDefaultConfiguration();
System.out.print("11");
BufferedImage result = gc.createCompatibleImage(destWidth, destHeight, source.getColorModel().getTransparency());
Graphics2D g2d = null;
System.out.print("12");
try {
g2d = result.createGraphics();
System.out.print("13");
//g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, interpolation);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
AffineTransform at =
AffineTransform.getScaleInstance(xScale, yScale);
System.out.print("14");
g2d.drawRenderedImage(source, at);
System.out.print("15");
} finally {
if (g2d != null) {
System.out.print("16");
g2d.dispose();
}
System.out.print("17");
}
System.out.print("18:"+result.toString());
return result;
}
public static GraphicsConfiguration getDefaultConfiguration() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
return gd.getDefaultConfiguration();
}
Was könnte den noch fehlen?
habe alles wie in der anleitung gemacht...
Lg,
Phil