-
ImageIO question
SOLVED - wrong filename. I used test.png instead of src/test.png.
Here's a piece of test code that simply draws a line on a newly created image and then puts the image into a png file. The png file is white in the beginning and no line appears after the program ends. Any idea why?
Code:
import java.awt.*;
import java.awt.image.*;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class ImageTest
{
public ImageTest()
{
BufferedImage bi = new BufferedImage(512, 512, BufferedImage.TYPE_INT_RGB);
Graphics2D g = bi.createGraphics();
g.drawLine(0, 0, 444, 444);
File out = new File("test.png");
try {
ImageIO.write(bi, "png", out);
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String args[])
{
ImageTest test = new ImageTest();
}
}
-
1 Attachment(s)
Re: ImageIO question
Attachment 2398
Thats my result of your code. The code looks right for me, should work